static.kuangkie.pc.bundle.56dd33c58bc93330344a.js Maven / Gradle / Ivy
"use strict";(self.webpackChunkaldehyde=self.webpackChunkaldehyde||[]).push([[623],{76623:function(e,t,r){r.d(t,{r:function(){return wu}});var n=r(96486),i=r(68636);function o(e){return o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o(e)}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function s(e,t){for(var r=0;re.length)&&(t=e.length);for(var r=0,n=new Array(t);rthis._prevTime+1e3&&(this._text.textContent=this.fps.toPrecision(2),this._prevTime=e),e}},{key:"update",value:function(){this._startTime=this.end()}},{key:"show",value:function(e){void 0===e&&(e=!0),this.domElement.style.display=e?"block":"none"}}]),e}();function P(e,t,r){return P=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}()?Reflect.construct:function(e,t,r){var n=[null];n.push.apply(n,t);var i=new(Function.bind.apply(e,n));return r&&u(i,r.prototype),i},P.apply(null,arguments)}function T(e){var t="function"==typeof Map?new Map:void 0;return T=function(e){if(null===e||(r=e,-1===Function.toString.call(r).indexOf("[native code]")))return e;var r;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return P(e,arguments,d(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),u(n,e)},T(e)}function M(e,t){return!e||e===t}function N(){this._handlers={}}N.prototype.addEventListener=function(e,t,r){var i=this._handlers[e];i||(this._handlers[e]=[],i=this._handlers[e]);var o=[t,r];void 0===(0,n.find)(i,(function(e){return e[0]===o[0]&&e[1]===o[1]}))&&i.push(o)},N.prototype.removeEventListener=function(e,t,r){var i=this;(0,n.forEach)(i._handlers,(function(o,a){(0,n.remove)(o,(function(n){return M(e,a)&&M(t,n[0])&&M(r,n[1]||i)}))})),this._handlers=(0,n.omitBy)(i._handlers,(function(e){return 0===e.length}))},N.prototype.dispatchEvent=function(e){var t=this;(0,n.forEach)(this._handlers[e.type],(function(r){var n=r[1]||t;r[0].apply(n,[e])}))};var I={debug:0,info:1,report:2,warn:3,error:4};function O(){N.call(this),this.console=!1,this._priority=I.warn}function L(e){if(!(0,n.isNumber)(e))throw new Error("Wrong log level specified!");return e}O.prototype=Object.create(N.prototype),O.prototype.constructor=O,O.prototype.instantiate=function(){return new O},Object.defineProperty(O.prototype,"level",{get:function(){var e=this;return(0,n.findKey)(I,(function(t){return t===e._priority}))},set:function(e){this._priority=L(I[e])}}),O.prototype.levels=function(){return Object.keys(I)},O.prototype.message=function(e,t){var r=L(I[e]);this._message(r,t)},O.prototype.debug=function(e){this._message(I.debug,e)},O.prototype.info=function(e){this._message(I.info,e)},O.prototype.report=function(e){this._message(I.report,e)},O.prototype.warn=function(e){this._message(I.warn,e)},O.prototype.error=function(e){this._message(I.error,e)},O.prototype._message=function(e,t){if(!(e=3&&"base64"===t[r-2]?new Blob([j(t[r-1])]):null}var X=/^[a-zA-Z0-9_]*$/,q=['"',"",'"'],$={browserType:D,encodeQueryComponent:function(e,t){return encodeURIComponent(e).replace(t,(function(e){return String.fromCharCode(parseInt(e.substr(1),16))})).replace(/%20/g,"+")},decodeQueryComponent:z,getUrlParameters:F,getUrlParametersAsDict:function(e){for(var t={},r=F(e),n=0;n0&&(o=Object.create(o))}return o},hexColor:function(e){var t="0000000".concat(e.toString(16)).substr(-6);return"#".concat(t)},DebugTracer:V,OutOfMemoryError:U,allocateTyped:function(e,t){var r=null;try{r=new e(t)}catch(e){throw e instanceof RangeError?new U(e.message):e}return r},bytesFromBase64:j,bytesToBase64:G,arrayFromBase64:function(e,t){return Array.prototype.slice.call(new t(j(e)))},arrayToBase64:function(e,t){return G(new t(e).buffer)},compareOptionsWithDefaults:function(e,t){var r=[];if(t&&e){for(var n=Object.keys(e),i=0;i0)return"!".concat(r.join())}return""},objectsDiff:function e(t,r){var i={};return(0,n.forIn)(t,(function(t,o){var a=r[o];if(H(t)&&H(a)){var s=e(t,a);(0,n.isEmpty)(s)||(i[o]=s)}else(0,n.isEqual)(t,a)||(i[o]=t)})),i},forInRecursive:function(e,t){!function e(r,i){(0,n.forIn)(r,(function(r,n){var o=i+(i.length>0?".":"");r instanceof Object?e(r,o+n):void 0!==r&&t(r,o+n)}))}(e,"")},enquoteString:function(e){return(0,n.isString)(e)?'"'.concat(e.replace(/"/g,'\\"'),'"'):e},unquoteString:function(e){if(!(0,n.isString)(e))return e;if('"'===e[0]&&'"'===e[e.length-1])return(e=e.slice(1,e.length-1)).replace(/\\"/g,'"');if("'"===e[0]&&"'"===e[e.length-1])return(e=e.slice(1,e.length-1)).replace(/\\'/g,"'");throw new SyntaxError("Incorrect string format, can't unqute it")},getBrowser:function(){return navigator.vendor&&navigator.vendor.indexOf("Apple")>-1&&navigator.userAgent&&-1===navigator.userAgent.indexOf("CriOS")&&-1===navigator.userAgent.indexOf("FxiOS")?D.SAFARI:D.DEFAULT},shotOpen:function(e){"undefined"!=typeof window&&window.open().document.write(''))},shotDownload:function(e,t){if(e&&"data:"===e.substr(0,5))if(t||(t=["screenshot-",+new Date,".png"].join("")),"undefined"!=typeof window&&window.navigator&&window.navigator.msSaveBlob)window.navigator.msSaveBlob(Y(e),t);else if("undefined"!=typeof document){var r=document.createElement("a");r.download=t,r.innerHTML="download",r.href=window.URL.createObjectURL(Y(e)),document.body.appendChild(r),r.click(),document.body.removeChild(r)}},copySubArrays:function(e,t,r,n){for(var i=0,o=r.length;i=0?(t.push(e.substr(r+1).split(",")),e.substr(0,r)):e}(e.substr(0,i>=0?i:void 0),r);if(i>=0){var s=e.substr(i+1).split(ie);if(e=a,t){var l=t[e],c=$.deriveDeep(l,!0);s.forEach((function(t){var r=t.split(ne,2),i=decodeURIComponent(r[0]),a=decodeURIComponent(r[1]),s=re[o((0,n.get)(l,i))];s?(0,n.set)(c,i,s(a)):B.warn('Unknown argument "'.concat(i,'" for option "').concat(e,'"'))})),Object.keys(c).length>0&&(e=[e,c])}}else e=a}return e}var de={l:"load",load:String,t:"type",type:String,v:"view",view:String,u:"unit",unit:Number,menu:te,o:"object",object:function(e,t){var r=[],n=fe(e,J.defaults.objects,r);Array.isArray(n)||(n=[n]),function(e,t,r){void 0===e._objects&&(e._objects=[]);var n=v(r,2),i=n[0],o=n[1],a={type:i,params:t};void 0!==o&&(a.opts=o),e._objects[e._objects.length]=a}(t,r[0],n)},p:"preset",preset:function(e,t){t.preset=e,t.reps=null,ue(t)},r:"rep",rep:function(e,t){ue(t),(ee=(ee=Number(e))<=t.reps.length?ee<0?0:ee:t.reps.length)===t.reps.length&&(t.reps[ee]=ee>0?$.deriveDeep(t.reps[ee-1],!0):$.deriveDeep(J.defaults.presets.default[0],!0))},s:"select",select:function(e,t){he(t,"selector",e)},m:"mode",mode:function(e,t){he(t,"mode",fe(e,J.defaults.modes))},c:"color",color:function(e,t){he(t,"colorer",fe(e,J.defaults.colorers))},mt:"material",material:function(e,t){he(t,"material",fe(e,J.defaults.materials))},dup:function(e,t){ue(t);var r=t.reps,n=r[ee];r[ee=r.length]=$.deriveDeep(n,!0)},ar:"autoResolution"};function pe(e){ee=0;for(var t={},r=0,i=e.length;r0&&(t+=",".concat(e.params.join(","))),e.opts&&(t+="!"+me(e.opts)),t}}function _e(e){var t=[],r=0;return $.forInRecursive(e,(function(e,n){t[r++]="".concat(n,"=").concat($.enquoteString(e))})),t.join(" ")}function ge(e){return(0,n.isArray)(e)?e.length<2?e[0]:"".concat(e[0]," ").concat(_e(e[1])):e}function xe(e){if(e&&e.type){var t=e.type;return(0,n.isArray)(e.params)&&e.params.length>0&&(t+=" ".concat(e.params.map($.enquoteString).join(" "))),e.opts&&(t+=" ".concat(_e(e.opts))),t}}function be(e,t){var r=[],i=0;function o(e,t){null!=t&&(r[i++]=e+t)}return(0,n.isEmpty)(e)?null:(o("",t),o("s=",$.enquoteString(e.selector)),o("m=",ge(e.mode)),o("c=",ge(e.colorer)),o("mt=",ge(e.material)),r.join(" "))}var we={fromURL:function(e){return pe($.getUrlParameters(e))},fromAttr:function(e){return pe($.getUrlParameters("?".concat(e||"")))},adapters:re,toURL:function(e){var t=[],r=0;function i(e,n){null!=n&&(t[r++]=se(e)+"="+se(n))}i("l",e.load),i("u",e.unit),i("p",e.preset),function(e){if(e)for(var t=0,r=e.length;t0&&(o+="?".concat(t.join("&"))),o},toScript:function(e){var t=[],r=0;function n(e,n,i){if(null!=n){var o="string"==typeof n&&i?'"':"";t[r++]="".concat(e," ").concat(o).concat(n).concat(o).trim()}}return n("set","autobuild false"),n("load",e.load,!0),n("unit",e.unit),n("preset",e.preset),function(e){if(e)for(var t=0,r=e.length;t0?e:this.element.name.trim()}},{key:"forEachBond",value:function(e){for(var t=this.bonds,r=0,n=t.length;rr)throw new Error("In a bond atom indices must be in increasing order");this._order=n,this._type=i}return l(e,[{key:"getLeft",value:function(){return this._left}},{key:"getRight",value:function(){return this._right}},{key:"getOrder",value:function(){return this._order}},{key:"calcLength",value:function(){return this._left.position.distanceTo(this._right.position)}},{key:"_forEachNeighbour",value:function(e,t){for(var r=e.bonds,n=0,i=r.length;n0?++n:++i}function s(e){"C"===e.element.name&&a(e)}for(var l=[[this.forEachLevelOne,s],[this.forEachLevelOne,a],[this.forEachLevelTwo,s],[this.forEachLevelTwo,a]],c=0;cn)return t.multiplyScalar(-1);if(ir.bonds.length&&(n=r,i=t);for(var o=n,a=0,s=i.bonds,l=0,c=s.length;la&&u!==n&&(o=u,a=u.bonds.length)}var h=e(i),f=e(n).clone().sub(h),d=e(o).clone().sub(h);return d.crossVectors(f,d),d.lengthSq()<1e-4&&d.set(0,1,0),f.normalize(),d.normalize(),f.crossVectors(d,f),f.lengthSq()<1e-4&&f.set(0,1,0),f.normalize(),this._fixDir(h,f,e)}}]),e}();Se(ke,"BondType",Ae),ke.prototype.BondType=Ae;var Pe=["C3'","C3*","P","H5T","H3T"],Te=["OP1","O1P"],Me=["OP2","O2P"],Ne=["C3'","C3*","C1","C1'","C1*","P"],Ie=[{types:["A","DA","G","DG"],atoms:["N1"]},{types:["C","DC"],atoms:["N3"]},{types:["T","DT","U","DU"],atoms:["O4"]}],Oe=function(){function e(t,r,n,i){a(this,e),this._chain=t,this._component=null,this._type=r,this._sequence=n,this._icode=i,this._mask=1,this._index=-1,this._atoms=[],this._secondary=null,this._firstAtom=null,this._leadAtom=null,this._wingAtom=null,this._lastAtom=null,this._controlPoint=null,this._midPoint=null,this._wingVector=null,this._cylinders=null,this._isValid=!0,this._het=!1,this._molecule=null,this.temperature=null,this.occupancy=null}return l(e,[{key:"getChain",value:function(){return this._chain}},{key:"getMolecule",value:function(){return this._molecule}},{key:"getType",value:function(){return this._type}},{key:"getSequence",value:function(){return this._sequence}},{key:"getSecondary",value:function(){return this._secondary}},{key:"getICode",value:function(){return this._icode}},{key:"addAtom",value:function(e,t,r,n,i,o,a,s,l,c){var u=new Ce(this,e,t,r,n,i,o,a,s,l,c);return this._chain.getComplex().addAtom(u),this._atoms.push(u),this._het=this._het||i,u}},{key:"getAtomCount",value:function(){return this._atoms.length}},{key:"forEachAtom",value:function(e){for(var t=this._atoms,r=0,n=t.length;r1e-4&&o.length()>1e-4&&Math.abs(n.angleTo(o))>Math.PI/2&&o.negate(),o}},{key:"_innerFinalize",value:function(e,t,r,n,o,a){var s=null===t,l=a(this._leadAtom),c=new i.Pa4(l.x,l.y,l.z);if(o)this._detectLeadWing(n,r,a);else{if(s)n._midPoint=a(this._firstAtom).clone();else{var u=t._controlPoint;n._midPoint=u.clone().lerp(c,.5),n._wingVector=this.calcWing(u,c,a(e._wingAtom),t._wingVector)}n._controlPoint=c}}},{key:"_finalize2",value:function(e,t,r){this._innerFinalize(e,e,t,this,r,(function(e){return e.position}))}},{key:"isConnected",value:function(e){if(this._chain!==e._chain)return!1;if(this===e)return!0;var t=!1;return this.forEachAtom((function(r){for(var n=r.bonds,i=0,o=n.length;i0&&(this.temperature=n/r),i>0&&(this.occupancy=o/i),null!==this._leadAtom&&null!==this._wingAtom||(this._isValid=!1),null===this._leadAtom&&(this._leadAtom=this._firstAtom),null===this._wingAtom&&(this._wingAtom=this._lastAtom)}}]),e}(),Le=function(){function e(t,r,n){a(this,e),this._name=t,this._fullName=r,this.letterCode=n,this.flags=0}return l(e,[{key:"getName",value:function(){return this._name}}]),e}();function Be(e,t){for(var r=0,n=t.length;r1&&e[1]._wingVector){var s=e[1]._wingVector;e[0]._wingVector=new i.Pa4(s.x,s.y,s.z)}else e.length>0&&(e[0]._wingVector=new i.Pa4(1,0,0))}},{key:"updateToFrame",value:function(e){var t=this._residues,r=null,n=null,o=e._residues,a=t.length;function s(t){return e.getAtomPos(t.index)}for(var l=0;l1?o[t[1]._index]._wingVector:new i.Pa4(1,0,0)}},{key:"addResidue",value:function(e,t,r){var n=this._complex.getResidueType(e);null===n&&(n=this._complex.addResidueType(e));var i=new Oe(this,n,t,r);return this._complex.addResidue(i),this._residues.push(i),n.flags&(Le.Flags.NUCLEIC|Le.Flags.PROTEIN)&&(this.maxSequencet&&(this.minSequence=t)),i}},{key:"getResidueCount",value:function(){return this._residues.length}},{key:"forEachResidue",value:function(e){for(var t=this._residues,r=0,n=t.length;r2&&w.push("'"+this.terminals_[g]+"'");R=u.showPosition?"Parse error on line "+(s+1)+":\n"+u.showPosition()+"\nExpecting "+w.join(", ")+", got '"+(this.terminals_[m]||m)+"'":"Parse error on line "+(s+1)+": Unexpected "+(1==m?"end of input":"'"+(this.terminals_[m]||m)+"'"),this.parseError(R,{text:u.match,token:this.terminals_[m]||m,line:u.yylineno,loc:d,expected:w})}if(y[0]instanceof Array&&y.length>1)throw new Error("Parse Error: multiple actions possible at state: "+v+", token: "+m);switch(y[0]){case 1:t.push(m),n.push(u.yytext),i.push(u.yylloc),t.push(y[1]),m=null,l=u.yyleng,a=u.yytext,s=u.yylineno,d=u.yylloc;break;case 2:if(x=this.productions_[y[1]][1],C.$=n[n.length-x],C._$={first_line:i[i.length-(x||1)].first_line,last_line:i[i.length-1].last_line,first_column:i[i.length-(x||1)].first_column,last_column:i[i.length-1].last_column},p&&(C._$.range=[i[i.length-(x||1)].range[0],i[i.length-1].range[1]]),void 0!==(_=this.performAction.apply(C,[a,l,s,h.yy,y[1],n,i].concat(c))))return _;x&&(t=t.slice(0,-1*x*2),n=n.slice(0,-1*x),i=i.slice(0,-1*x)),t.push(this.productions_[y[1]][0]),n.push(C.$),i.push(C._$),b=o[t[t.length-2]][t[t.length-1]],t.push(b);break;case 3:return!0}}return!0}},v=function(){var e={EOF:1,parseError:function(e,t){if(!this.yy.parser)throw new Error(e);this.yy.parser.parseError(e,t)},setInput:function(e,t){return this.yy=t||this.yy||{},this._input=e,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},input:function(){var e=this._input[0];return this.yytext+=e,this.yyleng++,this.offset++,this.match+=e,this.matched+=e,e.match(/(?:\r\n?|\n).*/g)?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),e},unput:function(e){var t=e.length,r=e.split(/(?:\r\n?|\n)/g);this._input=e+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-t),this.offset-=t;var n=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),r.length-1&&(this.yylineno-=r.length-1);var i=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:r?(r.length===n.length?this.yylloc.first_column:0)+n[n.length-r.length].length-r[0].length:this.yylloc.first_column-t},this.options.ranges&&(this.yylloc.range=[i[0],i[0]+this.yyleng-t]),this.yyleng=this.yytext.length,this},more:function(){return this._more=!0,this},reject:function(){return this.options.backtrack_lexer?(this._backtrack=!0,this):this.parseError("Lexical error on line "+(this.yylineno+1)+". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},less:function(e){this.unput(this.match.slice(e))},pastInput:function(){var e=this.matched.substr(0,this.matched.length-this.match.length);return(e.length>20?"...":"")+e.substr(-20).replace(/\n/g,"")},upcomingInput:function(){var e=this.match;return e.length<20&&(e+=this._input.substr(0,20-e.length)),(e.substr(0,20)+(e.length>20?"...":"")).replace(/\n/g,"")},showPosition:function(){var e=this.pastInput(),t=new Array(e.length+1).join("-");return e+this.upcomingInput()+"\n"+t+"^"},test_match:function(e,t){var r,n,i;if(this.options.backtrack_lexer&&(i={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,yy:this.yy,conditionStack:this.conditionStack.slice(0),done:this.done},this.options.ranges&&(i.yylloc.range=this.yylloc.range.slice(0))),(n=e[0].match(/(?:\r\n?|\n).*/g))&&(this.yylineno+=n.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:n?n[n.length-1].length-n[n.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+e[0].length},this.yytext+=e[0],this.match+=e[0],this.matches=e,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._backtrack=!1,this._input=this._input.slice(e[0].length),this.matched+=e[0],r=this.performAction.call(this,this.yy,this,t,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),r)return r;if(this._backtrack){for(var o in i)this[o]=i[o];return!1}return!1},next:function(){if(this.done)return this.EOF;var e,t,r,n;this._input||(this.done=!0),this._more||(this.yytext="",this.match="");for(var i=this._currentRules(),o=0;ot[0].length)){if(t=r,n=o,this.options.backtrack_lexer){if(!1!==(e=this.test_match(r,i[o])))return e;if(this._backtrack){t=!1;continue}return!1}if(!this.options.flex)break}return t?!1!==(e=this.test_match(t,i[n]))&&e:""===this._input?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+". Unrecognized text.\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},lex:function(){return this.next()||this.lex()},begin:function(e){this.conditionStack.push(e)},popState:function(){return this.conditionStack.length-1>0?this.conditionStack.pop():this.conditionStack[0]},_currentRules:function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},topState:function(e){return(e=this.conditionStack.length-1-Math.abs(e||0))>=0?this.conditionStack[e]:"INITIAL"},pushState:function(e){this.begin(e)},stateStackSize:function(){return this.conditionStack.length},options:{"case-insensitive":!0},performAction:function(e,t,r,n){switch(r){case 0:break;case 1:return 20;case 2:return 7;case 3:return 8;case 4:return 9;case 5:return 12;case 6:return 16;case 7:return 14;case 8:return 10;case 9:return 11;case 10:return 19;case 11:return 21;case 12:return"<=";case 13:return">=";case 14:return"<";case 15:return">";case 16:return t.yytext=t.yytext.substr(1,t.yyleng-2),24;case 17:return 13;case 18:return 23;case 19:return 5;case 20:return"INVALID"}},rules:[/^(?:\s+)/i,/^(?:(-?(?:[1-9][0-9]+|[0-9]))\b)/i,/^(?:OR\b)/i,/^(?:AND\b)/i,/^(?:NOT\b)/i,/^(?:((ALL|NONE|HETATM|PROTEIN|BASIC|ACIDIC|CHARGED|POLAR|NONPOLAR|AROMATIC|NUCLEIC|PURINE|PYRIMIDINE|WATER|POLARH|NONPOLARH))\b)/i,/^(?:((NAME|ELEM|TYPE|RESIDUE|ICODE|CHAIN|ALTLOC))\b)/i,/^(?:((SERIAL|SEQUENCE|RESIDX))\b)/i,/^(?:\()/i,/^(?:\))/i,/^(?:,)/i,/^(?::)/i,/^(?:<=)/i,/^(?:>=)/i,/^(?:<)/i,/^(?:>)/i,/^(?:((?:"(?:\\.|[^\\"])*"|'(?:\\.|[^\\'])*')))/i,/^(?:(@[_A-Z0-9]+))/i,/^(?:([_A-Z0-9]+))/i,/^(?:$)/i,/^(?:.)/i],conditions:{INITIAL:{rules:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20],inclusive:!0}}};return e}();function y(){this.yy={}}return m.lexer=v,y.prototype=m,m.Parser=y,new y}(),Qe={parser:Ke};function Je(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=d(e);if(t){var i=d(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return f(this,r)}}var et=function(){function e(t,r){a(this,e),this.min=t,this.max=void 0===r?t:r}return l(e,[{key:"includes",value:function(e){return this.min<=e&&e<=this.max}},{key:"toString",value:function(){var e=this.min,t=this.max;return e===t?String(e):[e,t].join(":")}},{key:"toJSON",value:function(){return[this.min,this.max]}}]),e}(),tt=function(){function e(t){if(a(this,e),t instanceof this.constructor)return t;this._values=t instanceof Array?t.slice(0):t?[t]:[]}return l(e,[{key:"append",value:function(e){var t=this._values;return t[t.length]=e,this}},{key:"remove",value:function(e){var t=this._values,r=t.indexOf(e);return r>=0&&t.splice(r,1),this}},{key:"toString",value:function(){return this._values.join(",")}},{key:"toJSON",value:function(){for(var e=this._values,t=[],r=0,n=e.length;rthis.priority?"(".concat(this.rhs,")"):this.rhs;return"".concat(this.keyword," ").concat(e)}},{key:"toJSON",value:function(){return[this.name,this.rhs.toJSON()]}}]),r}(at);pt.prototype.priority=1;var mt=function(e){h(r,e);var t=ft(r);function r(e,n){var i;return a(this,r),(i=t.call(this)).lhs=e||dt,i.rhs=n||dt,i}return l(r,[{key:"toString",value:function(){var e=this.lhs.priority&&this.lhs.priority>this.priority?"(".concat(this.lhs,")"):this.lhs,t=this.rhs.priority&&this.rhs.priority>this.priority?"(".concat(this.rhs,")"):this.rhs;return"".concat(e," ").concat(this.keyword," ").concat(t)}},{key:"toJSON",value:function(){return[this.name,this.lhs.toJSON(),this.rhs.toJSON()]}}]),r}(at);function vt(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=d(e);if(t){var i=d(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return f(this,r)}}mt.prototype.priority=1e3;var yt={};function _t(e,t){var r=e.toLowerCase();t.prototype.keyword=r,t.prototype.name=e;var n=function(){for(var e=arguments.length,r=new Array(e),n=0;n0?this._selector=wt.keyword("Chain")(this.chains):this._selector=wt.keyword("None")()}}]),o}(St),Rt=function(){function e(t){a(this,e),this._complex=t,this._index=-1,this._residueIndices=[],this._cycles=[],this._subDivs=[],this._residueCount=0}return l(e,[{key:"getResidues",value:function(){return this._complex._residues}},{key:"getResidueCount",value:function(){return this._residueCount}},{key:"forEachResidue",value:function(e){for(var t=this._complex._residues,r=this._residueIndices,n=0,i=r.length;nt?e:t,i=r+(n<<14),o=32*(r+89237*n&1048575),a=0;a<32;a++){var s=this.hashBuffer[o+a];if(-1===s)break;if(s===i)return!1}if(a>=32)throw new Error("addPair: increase cMaxPairsForHashCode");if(this.hashBuffer[o+a]=i,this.numPairs>=this.numMaxPairs)throw new Error("addPair: increase num pairs");return o=4*this.numPairs,this.intBuffer[o]=r,this.intBuffer[o+1]=n,this.intBuffer[o+2]=i,this.numPairs++,!0}}]),e}();function Et(e){var t=e.element;if(t)return t.radiusBonding;throw new Error("_getBondingRadius: Logic error.")}var kt,Pt,Tt,Mt=function(){function e(t){a(this,e),this._complex=t,this._maxRad=1.8;var r=this._complex.getDefaultBoundaries().boundingBox;this._vBoxMin=r.min.clone(),this._vBoxMax=r.max.clone(),this._pairCollection=null}return l(e,[{key:"_addExistingPairs",value:function(){for(var e=this._complex.getAtoms(),t=e.length,r=0,n=this._pairCollection;ru*u||s<.001||c._pairCollection.addPair(o.index,e.index)}}},h=0;h.1)&&kt.dot(Pt)>=0});function Lt(e,t){for(var r=0;r3}function Gt(e){return console.assert(e.length>2),!0}var jt=function(){function e(t){a(this,e),this._complex=t;for(var r=new Array(t._bonds.length),n=new Array(t._bonds.length),i=0,o=r.length;ii[l]?++l:++s}return!1}},{key:"_tryBond",value:function(e,t,r){var n=[],o=this._bondsData,a=Bt(e,t),s=t.position.clone().sub(a.position),l=this._currStart,c=this,u=this._bondMarks,h=this._checkBond;u[e._index]=!0,h=void 0===h?Ft:h,t.forEachBond((function(a){if(h(a)&&a!==e&&!u[a._index]&&!c._haveSameCycle(o,e,a)){var f,d,p,m=Bt(a,t),v=m.position.clone().sub(t.position),y=m===l?-2:1-(d=v,p=(f=s).dot(d)/Math.sqrt(f.lengthSq()*d.lengthSq()),i.M8C.clamp(p,-1,1)),_=v.cross(s);if(Ot(_,r)){for(var g=0;g=e.z?t:Math.max(a,s)]}function Wt(e,t,r,n){var i=r-e.y,o=n-e.y,a=Math.sqrt(Math.max(t*t-i*i,0)),s=Math.sqrt(Math.max(t*t-o*o,0));return[Math.min(a,s),r<=e.y&&n>=e.y?t:Math.max(a,s)]}var Yt=function(){function e(t,r){a(this,e),this._box=t.clone();var n=new i.Pa4;t.getSize(n),this._count=n.clone().divide(r).floor().max(new i.Pa4(1,1,1)),this._last=this._count.clone().subScalar(1),this._cellSize=n.clone().divide(this._count),this._cellInnerR=.5*Math.min(Math.min(this._cellSize.x,this._cellSize.y),this._cellSize.z),this._cellOuterR=.5*Math.sqrt(this._cellSize.dot(this._cellSize));var o=this._count.x*this._count.y*this._count.z;this._voxels=$.allocateTyped(Int32Array,o);for(var s=0;s=0;r=this._atoms[r+1])t(this._atoms[r])}},{key:"_forEachVoxelWithinRadius",value:function(t,r,n){var i=e._xRange,o=e._yRange,a=e._zRange;if(r/this._cellInnerR<10)this._forEachVoxelWithinRadiusSimple(t,r,n);else{var s,l,c,u,h,f,d,p;a.set(t.z-r,t.z+r),a.subScalar(this._box.min.z).divideScalar(this._cellSize.z).floor().clampScalar(0,this._count.z-1);for(var m=a.x;m<=a.y;++m){h=[this._box.min.z+m*this._cellSize.z,this._box.min.z+(m+1)*this._cellSize.z],p=t.z-r<=h[0]&&h[1]<=t.z+r,s=Ht(t,r,h[0],h[1]),o.set(t.y-s[1],t.y+s[1]),o.subScalar(this._box.min.y).divideScalar(this._cellSize.y).floor().clampScalar(0,this._count.y-1);for(var v=o.x;v<=o.y;++v){u=[this._box.min.y+v*this._cellSize.y,this._box.min.y+(v+1)*this._cellSize.y],d=t.y-s[0]<=u[0]&&u[1]<=t.y+s[0],l=Wt(t,s[1],u[0],u[1]),i.set(t.x-l[1],t.x+l[1]),i.subScalar(this._box.min.x).divideScalar(this._cellSize.x).floor().clampScalar(0,this._count.x-1);for(var y=i.x;y<=i.y;++y)c=[this._box.min.x+y*this._cellSize.x,this._box.min.x+(y+1)*this._cellSize.x],f=t.x-l[0]<=c[0]&&c[1]<=t.x+l[0],n(y+this._count.x*(v+this._count.y*m),f&&d&&p)}}}}},{key:"_forEachVoxelWithinRadiusSimple",value:function(t,r,n){var i=e._xRange,o=e._yRange,a=e._zRange,s=e._vCenter,l=(r+this._cellOuterR)*(r+this._cellOuterR),c=-1;r>this._cellOuterR&&(c=(r-this._cellOuterR)*(r-this._cellOuterR)),i.set(t.x-r,t.x+r),i.subScalar(this._box.min.x).divideScalar(this._cellSize.x).floor(),i.x=Math.min(Math.max(i.x,0),this._count.x-1),i.y=Math.min(Math.max(i.y,0),this._count.x-1),o.set(t.y-r,t.y+r),o.subScalar(this._box.min.y).divideScalar(this._cellSize.y).floor(),o.x=Math.min(Math.max(o.x,0),this._count.y-1),o.y=Math.min(Math.max(o.y,0),this._count.y-1),a.set(t.z-r,t.z+r),a.subScalar(this._box.min.z).divideScalar(this._cellSize.z).floor(),a.x=Math.min(Math.max(a.x,0),this._count.z-1),a.y=Math.min(Math.max(a.y,0),this._count.z-1);for(var u=a.x;u<=a.y;++u){var h=[this._box.min.z+u*this._cellSize.z,this._box.min.z+(u+1)*this._cellSize.z];s.z=.5*(h[0]+h[1]);for(var f=o.x;f<=o.y;++f){var d=[this._box.min.y+f*this._cellSize.y,this._box.min.y+(f+1)*this._cellSize.y];s.y=.5*(d[0]+d[1]);for(var p=i.x;p<=i.y;++p){var m=[this._box.min.x+p*this._cellSize.x,this._box.min.x+(p+1)*this._cellSize.x];s.x=.5*(m[0]+m[1]);var v=t.distanceToSquared(s);v<=l&&n(p+this._count.x*(f+this._count.y*u),v<=c)}}}}},{key:"forEachAtomWithinRadius",value:function(e,t,r){var n=this,i=t*t;n._forEachVoxelWithinRadius(e,t,(function(t,o){o?n._forEachAtomInVoxel(t,r):n._forEachAtomInVoxel(t,(function(t){e.distanceToSquared(t.position)<=i&&r(t)}))}))}},{key:"forEachAtomWithinDistFromMasked",value:function(e,t,r,n){this._forEachAtomWithinDistFromGroup((function(r){e.forEachAtom((function(e){0!=(e.mask&t)&&r(e)}))}),r,n)}},{key:"forEachAtomWithinDistFromSelected",value:function(e,t,r,n){this._forEachAtomWithinDistFromGroup((function(r){e.forEachAtom((function(e){t.includesAtom(e)&&r(e)}))}),r,n)}},{key:"_forEachAtomWithinDistFromGroup",value:function(e,t,r){var n,i=this,o=t*t,a=[],s=[],l=0;e((function(e){i._forEachVoxelWithinRadius(e.position,t,(function(t,r){r?a[t]=-1:void 0===a[t]?(s.push(e),s.push(-1),a[t]=l,l+=2):-1!==a[t]&&(s.push(e),s.push(a[t]),a[t]=l,l+=2)}))}));var c=function(e){if(void 0!==a[n])if(-1!==(l=a[n])){for(;l>=0;l=s[l+1])if(e.position.distanceToSquared(s[l].position)1e3?this._buildVW():this._build()}return l(e,[{key:"isBond",value:function(e,t){if(this._hbonds[e]){var r=v(this._hbonds[e].acceptor,2),n=r[0],i=r[1];if(n&&n.residue===t&&n.energy<-.5)return!0;if(i&&i.residue===t&&i.energy<-.5)return!0}return!1}},{key:"_build",value:function(){for(var e=0;e0&&this._complex._residues[e-1].getType().flags&Le.Flags.PROTEIN&&t._sequence===this._complex._residues[e-1]._sequence+1&&(r=this._complex._residues[e-1]);for(var n=e+1;n0?n[a-1]:null)||0!=(t.getType().flags&Le.Flags.PROTEIN)&&e._sequence===t._sequence+1||(t=null),i.forEachAtomWithinRadius(this._residueGetCAlpha(e),5,s));function s(i){var a=i.residue;if(a._index!==e._index&&0!=(a.getType().flags&Le.Flags.PROTEIN)&&o.addPair(e._index,a._index)){var s=a._index>0?n[a._index-1]:null;!s||0!=(s.getType().flags&Le.Flags.PROTEIN)&&a._sequence===s._sequence+1||(s=null),r._calcHBondEnergy(t,e,a),a._index!==e._index+1&&r._calcHBondEnergy(s,a,e)}}}},{key:"_residueGetCAlpha",value:function(e){for(var t=0;t1&&(n1&&(n=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}function Qt(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r70}for(var l=1;l+4=b&&this._isHelixStart(e[_-b]._index,x);g?this._ss[e[_]._index]=nr.TURN:this._bend[e[_]._index]&&(this._ss[e[_]._index]=nr.BEND)}}},{key:"_residueGetCAlpha",value:function(e){for(var t=0;t0&&(a=i.dot(o)/Math.sqrt(s)),a}},{key:"_kappa",value:function(e,t,r){var n=this._residueGetCAlpha(t),i=this._residueGetCAlpha(e),o=this._residueGetCAlpha(r);if(null===n||null===i||null===o)return 180;var a=this._cosinusAngle(n,i,o,n),s=Math.sqrt(1-a*a);return 180*Math.atan2(s,a)/Math.PI}},{key:"_isHelixStart",value:function(e,t){return this._helixFlags[t][e]===rr.START||this._helixFlags[t][e]===rr.START_AND_END}},{key:"_buildBetaSheets",value:function(){for(var e=[],t=0;t=6||g>=w&&_<=S||(e[v].type===tr.PARALLEL?C-b<6&&w-g<3||C-b<3:x-R<6&&w-g<3||x-R<3)&&(e[v].i=e[v].i.concat(e[y].i),e[v].type===tr.PARALLEL?e[v].j=e[v].j.concat(e[y].j):e[v].j=e[y].j.concat(e[v].j),e.splice(y--,1))}for(var A=new Set,E=0;E0;){var T=A.values().next().value;A.delete(T);var M=new Set;M.add(T);var N=void 0;do{N=new Set;var I,O=Kt(M.values());try{for(O.s();!(I=O.n()).done;){var L,B=I.value,D=Kt(A.values());try{for(D.s();!(L=D.n()).done;){var z=L.value;this._areBridgesLinked(B,z)&&N.add(z)}}catch(e){D.e(e)}finally{D.f()}}}catch(e){O.e(e)}finally{O.f()}var F,V=Kt(N.values());try{for(V.s();!(F=V.n()).done;)T=F.value,M.add(T),A.delete(T)}catch(e){V.e(e)}finally{V.f()}}while(N.size>0);var U,G=Kt(M.values());try{for(G.s();!(U=G.n()).done;)(T=U.value).ladder=P,T.sheet=k,T.link=M,++P}catch(e){G.e(e)}finally{G.f()}++k}for(var j=0;j1&&($=nr.STRAND),H.type===tr.PARALLEL){for(var Z=0,K=0;K=0&&e=0;t--){var i=n[t];null===i._left||null===i._right?n.splice(t,1):(i._left.bonds.push(i),i._right.bonds.push(i))}var o=this._residues;for(t=0,r=o.length;t>1;e;)t<<=1,e>>=1;return t}cr.prototype.id="Complex",cr.prototype.name="";var hr=function(){function e(t,r,n,i,o,s){if(a(this,e),this._box=n.clone(),this._dimVec=Math.max(Math.floor(i||1),1),this._volumeInfo=s,r instanceof Array){var l=v(r,3);this._dimX=l[0],this._dimY=l[1],this._dimZ=l[2]}else this._dimX=r.x,this._dimY=r.y,this._dimZ=r.z;switch(this._dimX=Math.max(Math.floor(this._dimX),1),this._dimY=Math.max(Math.floor(this._dimY),1),this._dimZ=Math.max(Math.floor(this._dimZ),1),this._rowElements=this._dimVec*this._dimX,this._planeElements=this._rowElements*this._dimY,this._totalElements=this._planeElements*this._dimZ,this._data=o||$.allocateTyped(t,this._totalElements),this._dimVec){case 1:break;case 2:this.getValue=function(e,t,r){var n=e*this._dimVec+t*this._rowElements+r*this._planeElements;return[this._data[n],this._data[n+1]]},this.setValue=function(e,t,r,n,i){var o=e*this._dimVec+t*this._rowElements+r*this._planeElements;this._data[o]=n,this._data[o+1]=i},this.addValue=function(e,t,r,n,i){var o=e*this._dimVec+t*this._rowElements+r*this._planeElements;this._data[o]+=n,this._data[o+1]+=i};break;case 3:this.getValue=function(e,t,r){var n=e*this._dimVec+t*this._rowElements+r*this._planeElements;return[this._data[n],this._data[n+1],this._data[n+2]]},this.setValue=function(e,t,r,n,i,o){var a=e*this._dimVec+t*this._rowElements+r*this._planeElements;this._data[a]=n,this._data[a+1]=i,this._data[a+2]=o},this.addValue=function(e,t,r,n,i,o){var a=e*this._dimVec+t*this._rowElements+r*this._planeElements;this._data[a]+=n,this._data[a+1]+=i,this._data[a+2]+=o};break;default:throw new Error("Volume: invalid vector dimension")}}return l(e,[{key:"getValue",value:function(e,t,r){return this._data[e+t*this._rowElements+r*this._planeElements]}},{key:"setValue",value:function(e,t,r,n){this._data[e+t*this._rowElements+r*this._planeElements]=n}},{key:"addValue",value:function(e,t,r,n){this._data[e+t*this._rowElements+r*this._planeElements]+=n}},{key:"getDimensions",value:function(){return[this._dimX,this._dimY,this._dimZ]}},{key:"getBox",value:function(){return this._box}},{key:"getVolumeInfo",value:function(){return this._volumeInfo}},{key:"getCellSize",value:function(){var e=new i.Pa4;this._box.getSize(e);var t=new i.Pa4;return t.x=this._dimX>1?e.x/(this._dimX-1):0,t.y=this._dimY>1?e.y/(this._dimY-1):0,t.z=this._dimZ>1?e.z/(this._dimZ-1):0,t}},{key:"computeGradient",value:function(){if(1!==this._dimVec)return null;var t=new e(Float32Array,[this._dimX,this._dimY,this._dimZ],this._box,3),r=this.getCellSize(),n=new i.Pa4(-.5/r.x,-.5/r.y,-.5/r.z);function o(e,t,r){return Math.min(r,Math.max(t,e))}var a=this._dimX,s=this._dimY,l=this._dimZ,c=this._data;function u(e,t,r){return c[r*a*s+t*a+e]}for(var h=0;h=1?this.fov=e:this.fov=i.M8C.radToDeg(2*Math.atan(Math.tan(.5*i.M8C.degToRad(e))/this.aspect))},i.u37.prototype.updateHalfSized=function(e,t){var r=e.aspect,n=e.fov;e.aspect=r/2,e.setMinimalFov(t),e.updateProjectionMatrix(),this.update(e),e.aspect=r,e.fov=n,e.updateProjectionMatrix()},i.cPb.prototype.setDistanceToFit=function(e,t){this.position.z=e/Math.sin(.5*i.M8C.degToRad(t))},i.iMs.prototype.intersectVisibleObject=function(e,t,r,n){var o=this.intersectObject(e,!1);if(0===o.length)return null;var a,s=Math.min(t.near,r),l=o[0],c=new i.Pa4;for(a=0;a1e-5;)t=n,n=e/((i=1+r*n)*i);return 1/i}for(var o=new i.BKK(2,2,e,t),a=o.getAttribute("position"),s=0;s>xr[t]&1))return!0;return!1},processObjRenderOrder:function(e,t){var r=+("BA"!==t);e.traverse((function(e){e.isGroup&&(e.renderOrder=r)}))},applySelectionMaterial:function(e){e.traverse((function(e){"material"in e&&(e.material=e.material.clone(!0),e.material.setValues({depthFunc:i.vCF,overrideColor:!0,fog:!1,lights:!1,shadowmap:!1}),e.material.setUberOptions({fixedColor:new i.Ilk(16776960),zOffset:-1e-6}))}))},getMiddlePoint:function(e,t,r){var n=r||new i.Pa4;return n.set(0,0,0),n.addScaledVector(e,.5),n.addScaledVector(t,.5),n},LAYERS:gr};var Er={boundingBox:new i.ZzF(new i.Pa4(-1,-1,-1),new i.Pa4(1,1,1)),boundingSphere:new i.aLr(new i.Pa4(0,0,0),1)},kr=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(e,t){var r;return a(this,i),(r=n.call(this,e,t)).name=e,r._dataSource=t,r}return l(i,[{key:"release",value:function(){this.parent&&this.parent.remove(this)}},{key:"getDataSource",value:function(){return this._dataSource}},{key:"getBoundaries",value:function(){return Er}}]),i}(Ar.RCGroup);function Pr(e){return function(e){if(Array.isArray(e))return p(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||m(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Tr(e){return null==e||Array.isArray(e)?e:[e]}var Mr=function(){function e(){var t=this,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:["id"];a(this,e),this._list=[],this._dict={},this._indices=Pr(n),this._indices.forEach((function(e){t._dict[e]={}})),r.forEach((function(e){return t.register(e)}))}return l(e,[{key:"register",value:function(t){var r=this;e.registerInList(this._list,t),this._indices.forEach((function(n){e.registerInDict(r._dict[n],Tr(t[n]),t)}))}},{key:"unregister",value:function(t){var r=this;e.unregisterFromList(this._list,t),this._indices.forEach((function(n){e.unregisterFromDict(r._dict[n],Tr(t[n]),t)}))}},{key:"all",get:function(){return Pr(this._list)}},{key:"first",get:function(){return this._list[0]}},{key:"keys",value:function(e){return Object.keys(this._dict[e||this._indices[0]])}},{key:"get",value:function(e,t){var r=this._dict[t||this._indices[0]];if(r){var n=r[e&&e.toLowerCase()];return n&&n.length>0?n[0]:void 0}}}],[{key:"registerInList",value:function(e,t){e.includes(t)||e.push(t)}},{key:"unregisterFromList",value:function(e,t){var r=e.indexOf(t);-1!==r&&e.splice(r,1)}},{key:"registerInDict",value:function(e,t,r){t.forEach((function(t){t=t.toLowerCase();var n=e[t]=e[t]||[];n.includes(r)||n.push(r)}))}},{key:"unregisterFromDict",value:function(e,t,r){t.forEach((function(t){t=t.toLowerCase();var n=e[t];if(n){var i=n.indexOf(r);-1!==i&&n.splice(i,1),0===n.length&&delete e[t]}}))}}]),e}();function Nr(e){Object.defineProperties(e,{logger:{get:function(){return this.context&&this.context.logger?this.context.logger:B}},settings:{get:function(){return this.context&&this.context.settings?this.context.settings:J}}})}var Ir=function(){function e(t,r){a(this,e),this._position=t,this._radius=r}return l(e,[{key:"raycast",value:function(t){var r=e._sphere;r.set(this._position,this._radius);var n=new i.Pa4;return t.ray.intersectSphere(r,n)?{distance:t.ray.origin.distanceTo(n),point:n}:null}}]),e}();Se(Ir,"_sphere",new i.aLr);var Or=function(e){return function(e){h(o,e);var t,r,n=(t=o,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function o(e){var t;a(this,o);for(var r=arguments.length,i=new Array(r>1?r-1:0),s=1;s65535,c=a*t,u=this._index=$.allocateTyped(l?Uint32Array:Uint16Array,c);this._positions=$.allocateTyped(Float32Array,3*s),this._normals=$.allocateTyped(Float32Array,3*s),this._colors=$.allocateTyped(Float32Array,3*s);var h=this._alpha=$.allocateTyped(Float32Array,s);(0,n.fill)(h,1);for(var f=0;f0,d=!1===c&&t>0,p=(l+1)*s+f*(s+1)+d*(s+1),m=(2*l+f+d)*s,v=r/2,y=new i.TlE($.allocateTyped(Float32Array,3*p),3),_=new i.TlE($.allocateTyped(Float32Array,3*p),3),g=new i.qlB($.allocateTyped(Uint16Array,3*m),1),x=new i.TlE($.allocateTyped(Float32Array,2*p),2);console.assert(p<65536,"false: Cylinder Geometry has too many vertices (65536 max).");for(var b=0,w=0,S=-(t-e)/r,C=0;C<=l;C++){if(C!==l)for(var R=0;R2&&void 0!==arguments[2]&&arguments[2],n=arguments.length>3&&void 0!==arguments[3]&&arguments[3],i=this._chunkGeo._positions.length,o=this._ringsCount,a=i*this._ringsCount*e*3;this._setPoints(t,i,o,a),r?this._setSlopeNormals(i,o,a):this._setBaseNormals(i,o,a),n&&this._addCut(i,o,a)}},{key:"_setPoints",value:function(e,t,r,n){for(var i=this._tmpShape,o=this._positions,a=this._chunkGeo._positions,s=0,l=n;s0)for(var s=0;s2)for(var c=0;c65535;this._index=$.allocateTyped(r?Uint32Array:Uint16Array,6*e),this._positions=$.allocateTyped(Float32Array,4*t),this._colors=$.allocateTyped(Float32Array,3*t),this._directions=$.allocateTyped(Float32Array,3*t);var o=this._alpha=$.allocateTyped(Float32Array,t);(0,n.fill)(o,1);for(var a=this._index,s=0,l=0,c=0;c117440512)throw new Error("Too large cube dimension: lead to memory huge uasge");return this.pointsValuesLinear=$.allocateTyped(Float32Array,32*t),this.hasIntersection=$.allocateTyped(Int32Array,t),this.bitsInside=$.allocateTyped(Int32Array,t),0}},{key:"destroy",value:function(){this.bitsInside=null,this.hasIntersection=null,this.pointsValuesLinear=null}}]),e}();En.prototype.striIndicesMarchCube=[-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,-1,0,1,9,8,4,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,1,9,4,7,1,7,3,1,-1,-1,-1,-1,-1,-1,-1,1,2,10,8,4,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,4,7,3,0,4,1,2,10,-1,-1,-1,-1,-1,-1,-1,9,2,10,9,0,2,8,4,7,-1,-1,-1,-1,-1,-1,-1,2,10,9,2,9,7,2,7,3,7,9,4,-1,-1,-1,-1,8,4,7,3,11,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,11,4,7,11,2,4,2,0,4,-1,-1,-1,-1,-1,-1,-1,9,0,1,8,4,7,2,3,11,-1,-1,-1,-1,-1,-1,-1,4,7,11,9,4,11,9,11,2,9,2,1,-1,-1,-1,-1,3,10,1,3,11,10,7,8,4,-1,-1,-1,-1,-1,-1,-1,1,11,10,1,4,11,1,0,4,7,11,4,-1,-1,-1,-1,4,7,8,9,0,11,9,11,10,11,0,3,-1,-1,-1,-1,4,7,11,4,11,9,9,11,10,-1,-1,-1,-1,-1,-1,-1,9,5,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,5,4,0,8,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,5,4,1,5,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,5,4,8,3,5,3,1,5,-1,-1,-1,-1,-1,-1,-1,1,2,10,9,5,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,0,8,1,2,10,4,9,5,-1,-1,-1,-1,-1,-1,-1,5,2,10,5,4,2,4,0,2,-1,-1,-1,-1,-1,-1,-1,2,10,5,3,2,5,3,5,4,3,4,8,-1,-1,-1,-1,9,5,4,2,3,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,11,2,0,8,11,4,9,5,-1,-1,-1,-1,-1,-1,-1,0,5,4,0,1,5,2,3,11,-1,-1,-1,-1,-1,-1,-1,2,1,5,2,5,8,2,8,11,4,8,5,-1,-1,-1,-1,10,3,11,10,1,3,9,5,4,-1,-1,-1,-1,-1,-1,-1,4,9,5,0,8,1,8,10,1,8,11,10,-1,-1,-1,-1,5,4,0,5,0,11,5,11,10,11,0,3,-1,-1,-1,-1,5,4,8,5,8,10,10,8,11,-1,-1,-1,-1,-1,-1,-1,9,7,8,5,7,9,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,3,0,9,5,3,5,7,3,-1,-1,-1,-1,-1,-1,-1,0,7,8,0,1,7,1,5,7,-1,-1,-1,-1,-1,-1,-1,1,5,3,3,5,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,7,8,9,5,7,10,1,2,-1,-1,-1,-1,-1,-1,-1,10,1,2,9,5,0,5,3,0,5,7,3,-1,-1,-1,-1,8,0,2,8,2,5,8,5,7,10,5,2,-1,-1,-1,-1,2,10,5,2,5,3,3,5,7,-1,-1,-1,-1,-1,-1,-1,7,9,5,7,8,9,3,11,2,-1,-1,-1,-1,-1,-1,-1,9,5,7,9,7,2,9,2,0,2,7,11,-1,-1,-1,-1,2,3,11,0,1,8,1,7,8,1,5,7,-1,-1,-1,-1,11,2,1,11,1,7,7,1,5,-1,-1,-1,-1,-1,-1,-1,9,5,8,8,5,7,10,1,3,10,3,11,-1,-1,-1,-1,5,7,0,5,0,9,7,11,0,1,0,10,11,10,0,-1,11,10,0,11,0,3,10,5,0,8,0,7,5,7,0,-1,11,10,5,7,11,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,10,6,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,8,3,5,10,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,0,1,5,10,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,8,3,1,9,8,5,10,6,-1,-1,-1,-1,-1,-1,-1,1,6,5,2,6,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,6,5,1,2,6,3,0,8,-1,-1,-1,-1,-1,-1,-1,9,6,5,9,0,6,0,2,6,-1,-1,-1,-1,-1,-1,-1,5,9,8,5,8,2,5,2,6,3,2,8,-1,-1,-1,-1,2,3,11,10,6,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,11,0,8,11,2,0,10,6,5,-1,-1,-1,-1,-1,-1,-1,0,1,9,2,3,11,5,10,6,-1,-1,-1,-1,-1,-1,-1,5,10,6,1,9,2,9,11,2,9,8,11,-1,-1,-1,-1,6,3,11,6,5,3,5,1,3,-1,-1,-1,-1,-1,-1,-1,0,8,11,0,11,5,0,5,1,5,11,6,-1,-1,-1,-1,3,11,6,0,3,6,0,6,5,0,5,9,-1,-1,-1,-1,6,5,9,6,9,11,11,9,8,-1,-1,-1,-1,-1,-1,-1,5,10,6,4,7,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,3,0,4,7,3,6,5,10,-1,-1,-1,-1,-1,-1,-1,1,9,0,5,10,6,8,4,7,-1,-1,-1,-1,-1,-1,-1,10,6,5,1,9,7,1,7,3,7,9,4,-1,-1,-1,-1,6,1,2,6,5,1,4,7,8,-1,-1,-1,-1,-1,-1,-1,1,2,5,5,2,6,3,0,4,3,4,7,-1,-1,-1,-1,8,4,7,9,0,5,0,6,5,0,2,6,-1,-1,-1,-1,7,3,9,7,9,4,3,2,9,5,9,6,2,6,9,-1,3,11,2,7,8,4,10,6,5,-1,-1,-1,-1,-1,-1,-1,5,10,6,4,7,2,4,2,0,2,7,11,-1,-1,-1,-1,0,1,9,4,7,8,2,3,11,5,10,6,-1,-1,-1,-1,9,2,1,9,11,2,9,4,11,7,11,4,5,10,6,-1,8,4,7,3,11,5,3,5,1,5,11,6,-1,-1,-1,-1,5,1,11,5,11,6,1,0,11,7,11,4,0,4,11,-1,0,5,9,0,6,5,0,3,6,11,6,3,8,4,7,-1,6,5,9,6,9,11,4,7,9,7,11,9,-1,-1,-1,-1,10,4,9,6,4,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,10,6,4,9,10,0,8,3,-1,-1,-1,-1,-1,-1,-1,10,0,1,10,6,0,6,4,0,-1,-1,-1,-1,-1,-1,-1,8,3,1,8,1,6,8,6,4,6,1,10,-1,-1,-1,-1,1,4,9,1,2,4,2,6,4,-1,-1,-1,-1,-1,-1,-1,3,0,8,1,2,9,2,4,9,2,6,4,-1,-1,-1,-1,0,2,4,4,2,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,3,2,8,2,4,4,2,6,-1,-1,-1,-1,-1,-1,-1,10,4,9,10,6,4,11,2,3,-1,-1,-1,-1,-1,-1,-1,0,8,2,2,8,11,4,9,10,4,10,6,-1,-1,-1,-1,3,11,2,0,1,6,0,6,4,6,1,10,-1,-1,-1,-1,6,4,1,6,1,10,4,8,1,2,1,11,8,11,1,-1,9,6,4,9,3,6,9,1,3,11,6,3,-1,-1,-1,-1,8,11,1,8,1,0,11,6,1,9,1,4,6,4,1,-1,3,11,6,3,6,0,0,6,4,-1,-1,-1,-1,-1,-1,-1,6,4,8,11,6,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7,10,6,7,8,10,8,9,10,-1,-1,-1,-1,-1,-1,-1,0,7,3,0,10,7,0,9,10,6,7,10,-1,-1,-1,-1,10,6,7,1,10,7,1,7,8,1,8,0,-1,-1,-1,-1,10,6,7,10,7,1,1,7,3,-1,-1,-1,-1,-1,-1,-1,1,2,6,1,6,8,1,8,9,8,6,7,-1,-1,-1,-1,2,6,9,2,9,1,6,7,9,0,9,3,7,3,9,-1,7,8,0,7,0,6,6,0,2,-1,-1,-1,-1,-1,-1,-1,7,3,2,6,7,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,3,11,10,6,8,10,8,9,8,6,7,-1,-1,-1,-1,2,0,7,2,7,11,0,9,7,6,7,10,9,10,7,-1,1,8,0,1,7,8,1,10,7,6,7,10,2,3,11,-1,11,2,1,11,1,7,10,6,1,6,7,1,-1,-1,-1,-1,8,9,6,8,6,7,9,1,6,11,6,3,1,3,6,-1,0,9,1,11,6,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7,8,0,7,0,6,3,11,0,11,6,0,-1,-1,-1,-1,7,11,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7,6,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,0,8,11,7,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,1,9,11,7,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,1,9,8,3,1,11,7,6,-1,-1,-1,-1,-1,-1,-1,10,1,2,6,11,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,2,10,3,0,8,6,11,7,-1,-1,-1,-1,-1,-1,-1,2,9,0,2,10,9,6,11,7,-1,-1,-1,-1,-1,-1,-1,6,11,7,2,10,3,10,8,3,10,9,8,-1,-1,-1,-1,7,2,3,6,2,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7,0,8,7,6,0,6,2,0,-1,-1,-1,-1,-1,-1,-1,2,7,6,2,3,7,0,1,9,-1,-1,-1,-1,-1,-1,-1,1,6,2,1,8,6,1,9,8,8,7,6,-1,-1,-1,-1,10,7,6,10,1,7,1,3,7,-1,-1,-1,-1,-1,-1,-1,10,7,6,1,7,10,1,8,7,1,0,8,-1,-1,-1,-1,0,3,7,0,7,10,0,10,9,6,10,7,-1,-1,-1,-1,7,6,10,7,10,8,8,10,9,-1,-1,-1,-1,-1,-1,-1,6,8,4,11,8,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,6,11,3,0,6,0,4,6,-1,-1,-1,-1,-1,-1,-1,8,6,11,8,4,6,9,0,1,-1,-1,-1,-1,-1,-1,-1,9,4,6,9,6,3,9,3,1,11,3,6,-1,-1,-1,-1,6,8,4,6,11,8,2,10,1,-1,-1,-1,-1,-1,-1,-1,1,2,10,3,0,11,0,6,11,0,4,6,-1,-1,-1,-1,4,11,8,4,6,11,0,2,9,2,10,9,-1,-1,-1,-1,10,9,3,10,3,2,9,4,3,11,3,6,4,6,3,-1,8,2,3,8,4,2,4,6,2,-1,-1,-1,-1,-1,-1,-1,0,4,2,4,6,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,9,0,2,3,4,2,4,6,4,3,8,-1,-1,-1,-1,1,9,4,1,4,2,2,4,6,-1,-1,-1,-1,-1,-1,-1,8,1,3,8,6,1,8,4,6,6,10,1,-1,-1,-1,-1,10,1,0,10,0,6,6,0,4,-1,-1,-1,-1,-1,-1,-1,4,6,3,4,3,8,6,10,3,0,3,9,10,9,3,-1,10,9,4,6,10,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,9,5,7,6,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,8,3,4,9,5,11,7,6,-1,-1,-1,-1,-1,-1,-1,5,0,1,5,4,0,7,6,11,-1,-1,-1,-1,-1,-1,-1,11,7,6,8,3,4,3,5,4,3,1,5,-1,-1,-1,-1,9,5,4,10,1,2,7,6,11,-1,-1,-1,-1,-1,-1,-1,6,11,7,1,2,10,0,8,3,4,9,5,-1,-1,-1,-1,7,6,11,5,4,10,4,2,10,4,0,2,-1,-1,-1,-1,3,4,8,3,5,4,3,2,5,10,5,2,11,7,6,-1,7,2,3,7,6,2,5,4,9,-1,-1,-1,-1,-1,-1,-1,9,5,4,0,8,6,0,6,2,6,8,7,-1,-1,-1,-1,3,6,2,3,7,6,1,5,0,5,4,0,-1,-1,-1,-1,6,2,8,6,8,7,2,1,8,4,8,5,1,5,8,-1,9,5,4,10,1,6,1,7,6,1,3,7,-1,-1,-1,-1,1,6,10,1,7,6,1,0,7,8,7,0,9,5,4,-1,4,0,10,4,10,5,0,3,10,6,10,7,3,7,10,-1,7,6,10,7,10,8,5,4,10,4,8,10,-1,-1,-1,-1,6,9,5,6,11,9,11,8,9,-1,-1,-1,-1,-1,-1,-1,3,6,11,0,6,3,0,5,6,0,9,5,-1,-1,-1,-1,0,11,8,0,5,11,0,1,5,5,6,11,-1,-1,-1,-1,6,11,3,6,3,5,5,3,1,-1,-1,-1,-1,-1,-1,-1,1,2,10,9,5,11,9,11,8,11,5,6,-1,-1,-1,-1,0,11,3,0,6,11,0,9,6,5,6,9,1,2,10,-1,11,8,5,11,5,6,8,0,5,10,5,2,0,2,5,-1,6,11,3,6,3,5,2,10,3,10,5,3,-1,-1,-1,-1,5,8,9,5,2,8,5,6,2,3,8,2,-1,-1,-1,-1,9,5,6,9,6,0,0,6,2,-1,-1,-1,-1,-1,-1,-1,1,5,8,1,8,0,5,6,8,3,8,2,6,2,8,-1,1,5,6,2,1,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,3,6,1,6,10,3,8,6,5,6,9,8,9,6,-1,10,1,0,10,0,6,9,5,0,5,6,0,-1,-1,-1,-1,0,3,8,5,6,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,10,5,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,11,5,10,7,5,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,11,5,10,11,7,5,8,3,0,-1,-1,-1,-1,-1,-1,-1,5,11,7,5,10,11,1,9,0,-1,-1,-1,-1,-1,-1,-1,10,7,5,10,11,7,9,8,1,8,3,1,-1,-1,-1,-1,11,1,2,11,7,1,7,5,1,-1,-1,-1,-1,-1,-1,-1,0,8,3,1,2,7,1,7,5,7,2,11,-1,-1,-1,-1,9,7,5,9,2,7,9,0,2,2,11,7,-1,-1,-1,-1,7,5,2,7,2,11,5,9,2,3,2,8,9,8,2,-1,2,5,10,2,3,5,3,7,5,-1,-1,-1,-1,-1,-1,-1,8,2,0,8,5,2,8,7,5,10,2,5,-1,-1,-1,-1,9,0,1,5,10,3,5,3,7,3,10,2,-1,-1,-1,-1,9,8,2,9,2,1,8,7,2,10,2,5,7,5,2,-1,1,3,5,3,7,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,8,7,0,7,1,1,7,5,-1,-1,-1,-1,-1,-1,-1,9,0,3,9,3,5,5,3,7,-1,-1,-1,-1,-1,-1,-1,9,8,7,5,9,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,5,8,4,5,10,8,10,11,8,-1,-1,-1,-1,-1,-1,-1,5,0,4,5,11,0,5,10,11,11,3,0,-1,-1,-1,-1,0,1,9,8,4,10,8,10,11,10,4,5,-1,-1,-1,-1,10,11,4,10,4,5,11,3,4,9,4,1,3,1,4,-1,2,5,1,2,8,5,2,11,8,4,5,8,-1,-1,-1,-1,0,4,11,0,11,3,4,5,11,2,11,1,5,1,11,-1,0,2,5,0,5,9,2,11,5,4,5,8,11,8,5,-1,9,4,5,2,11,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,5,10,3,5,2,3,4,5,3,8,4,-1,-1,-1,-1,5,10,2,5,2,4,4,2,0,-1,-1,-1,-1,-1,-1,-1,3,10,2,3,5,10,3,8,5,4,5,8,0,1,9,-1,5,10,2,5,2,4,1,9,2,9,4,2,-1,-1,-1,-1,8,4,5,8,5,3,3,5,1,-1,-1,-1,-1,-1,-1,-1,0,4,5,1,0,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,4,5,8,5,3,9,0,5,0,3,5,-1,-1,-1,-1,9,4,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,11,7,4,9,11,9,10,11,-1,-1,-1,-1,-1,-1,-1,0,8,3,4,9,7,9,11,7,9,10,11,-1,-1,-1,-1,1,10,11,1,11,4,1,4,0,7,4,11,-1,-1,-1,-1,3,1,4,3,4,8,1,10,4,7,4,11,10,11,4,-1,4,11,7,9,11,4,9,2,11,9,1,2,-1,-1,-1,-1,9,7,4,9,11,7,9,1,11,2,11,1,0,8,3,-1,11,7,4,11,4,2,2,4,0,-1,-1,-1,-1,-1,-1,-1,11,7,4,11,4,2,8,3,4,3,2,4,-1,-1,-1,-1,2,9,10,2,7,9,2,3,7,7,4,9,-1,-1,-1,-1,9,10,7,9,7,4,10,2,7,8,7,0,2,0,7,-1,3,7,10,3,10,2,7,4,10,1,10,0,4,0,10,-1,1,10,2,8,7,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,9,1,4,1,7,7,1,3,-1,-1,-1,-1,-1,-1,-1,4,9,1,4,1,7,0,8,1,8,7,1,-1,-1,-1,-1,4,0,3,7,4,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,8,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,10,8,10,11,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,0,9,3,9,11,11,9,10,-1,-1,-1,-1,-1,-1,-1,0,1,10,0,10,8,8,10,11,-1,-1,-1,-1,-1,-1,-1,3,1,10,11,3,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,2,11,1,11,9,9,11,8,-1,-1,-1,-1,-1,-1,-1,3,0,9,3,9,11,1,2,9,2,11,9,-1,-1,-1,-1,0,2,11,8,0,11,-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];var kn=[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],Pn=l((function e(){a(this,e),this._arrSize=8,this.p=new Array(this._arrSize),this.g=new Array(this._arrSize),this.val=new Array(this._arrSize);for(var t=0;tNumber.EPSILON};return!(c(t.y)||c(t.z)||c(r.x)||c(r.z)||c(n.x)||c(n.y))}},{key:"_vertexInterp",value:function(e,t,r,n,i,o){var a=t.p[r],s=t.p[n],l=t.g[r],c=t.g[n],u=t.val[r],h=e-u,f=t.val[n]-u,d=0;Math.abs(f)>0&&(d=h/f),d=d>1?1:d,i.lerpVectors(a,s,d),o.lerpVectors(l,c,d)}},{key:"_polygonize",value:function(t,r,n){for(var i=t.cubeIndex,o=0,a=e._arrSize,s=e._firstIndices,l=e._secondIndices,c=e._vertexList,u=e._normalList;os?s:c+t,h=-1,f=c;fU&&(G=j,U=R[j]);if(G<0||!n.includesAtom(C[G])){P[i]=-1;continue}}P[i]=T++;var H=L=0&&ie>=0&&oe>=0&&(this._indices[3*re]=ne,this._indices[3*re+1]=ie,this._indices[3*re+2]=oe,++re)}this._position=new Float32Array(this._position.buffer.slice(0,3*T*4)),this._normals=new Float32Array(this._normals.buffer.slice(0,3*T*4)),this._colors=new Float32Array(this._colors.buffer.slice(0,3*T*4)),this._indices=new Uint32Array(this._indices.buffer.slice(0,3*re*4))}}},{key:"toMesh",value:function(){var e=new i.u9r;return e.setIndex(new i.TlE(this._indices,1)),e.setAttribute("position",new i.TlE(this._position,3)),e.setAttribute("normal",new i.TlE(this._normals,3)),e.setAttribute("color",new i.TlE(this._colors,3)),e.computeBoundingSphere(),e}}]),e}();Se(Nn,"_triTable",En.prototype.striIndicesMarchCube),Se(Nn,"_arrSize",12),Se(Nn,"_firstIndices",[0,1,2,3,4,5,6,7,0,1,2,3]),Se(Nn,"_secondIndices",[1,2,3,0,5,6,7,4,4,5,6,7]),Se(Nn,"_vertexList",Mn(Nn._arrSize)),Se(Nn,"_normalList",Mn(Nn._arrSize));var In=function(e){h(o,e);var t,r,n=(t=o,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function o(){return a(this,o),n.apply(this,arguments)}return l(o,[{key:"_build",value:function(){var e=this._opts;this.numVoxels=[128,128,128],this.xAxis=new i.Pa4(1,0,0),this.yAxis=new i.Pa4(0,1,0),this.zAxis=new i.Pa4(0,0,1),this.origin=new i.Pa4(0,0,0),this._visibilitySelector=e.visibilitySelector,this._calcSurface(e)}},{key:"_findMinMax",value:function(e){for(var t=e.length/4,r=[e[0],e[1],e[2],e[3]],n=[e[0],e[1],e[2],e[3]],i=1;i4&&(t.gridSpacing*=i[3]);var a=t.radScale*o[3]*1.7,s=a;s=.65*Math.sqrt(4/3*Math.PI*s*s*s),a=Math.max(a,s);for(var l=0;l<3;++l)i[l]-=a,o[l]+=a;for(l=0;l<3;++l)r[l]=Math.ceil((o[l]-i[l])/t.gridSpacing);this.xAxis.x=(r[0]-1)*t.gridSpacing,this.yAxis.y=(r[1]-1)*t.gridSpacing,this.zAxis.z=(r[2]-1)*t.gridSpacing;var c=v(i,3);return this.origin.x=c[0],this.origin.y=c[1],this.origin.z=c[2],{bbox:n,dim:r}}},{key:"_makeSurface",value:function(e,t){var r=new Nn;r.compute(e.volMap,this.origin,t.isoValue,1),r.vertexFusion(9,9),r._numTriangles>0?(r.setColorVolTex(e.volTexMap,e.atomMap,e.atomWeightMap,this._visibilitySelector),this.setIndex(new i.TlE(r._indices,1)),this.setAttribute("position",new i.TlE(r._position,3)),this.setAttribute("normal",new i.TlE(r._normals,3)),this.setAttribute("color",new i.TlE(r._colors,3))):this.setAttribute("position",new i.TlE($.allocateTyped(Float32Array,0),3))}},{key:"_calcSurface",value:function(e){var t={posRad:this._posRad,colors:this._colors,atoms:this._opts.atoms};if(0!==t.posRad.length){var r=this._findNumVoxels(t.posRad,e),n=new i.ZzF(this.origin,new i.Pa4(this.xAxis.x,this.yAxis.y,this.zAxis.z).add(this.origin)),o=this._computeSurface(t,n,r,e);this._makeSurface(o,e)}}}]),o}(An);var On=dr.Volume,Ln=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(){return a(this,i),n.apply(this,arguments)}return l(i,[{key:"_computeSurface",value:function(e,t,r,n){this._shiftByOrigin(e.posRad);var i={volMap:new On(Float32Array,this.numVoxels,t),volTexMap:new On(Float32Array,this.numVoxels,t,3)};return null!=this._visibilitySelector&&(i.atomMap=[],i.atomWeightMap=new On(Float32Array,this.numVoxels,t)),this.gaussdensity(i,e,null,n),i}},{key:"gaussdensity",value:function(e,t,r,n){var i,o=t.posRad.length/4,a=t.posRad,s=t.colors,l=this.numVoxels,c=n.radScale,u=n.gaussLim,h=n.gridSpacing,f=1/n.isoValue,d=1/h,p=l[0]-1,m=l[1]-1,v=l[2]-1,y=e.volMap,_=e.volTexMap,g=y.getData(),x=y.getStrideX(),b=_.getData(),w=_.getStrideX();null!=this._visibilitySelector&&(i=e.atomWeightMap.getData());for(var S=e.atomMap,C=0;C=T))for(var j=y.getDirectIdx(N,U,F),H=_.getDirectIdx(N,U,F),W=N*h-a[R],Y=N;Y<=I;++Y,W+=h,j+=x,H+=w){var X=-(W*W+G)*k,q=Math.exp(X)*E;null!=this._visibilitySelector&&q>i[j]&&(i[j]=q,S[j]=t.atoms[C]),g[j]+=q,q*=f;var $=3*C;b[H]+=q*s[$],b[H+1]+=q*s[$+1],b[H+2]+=q*s[$+2]}}}}},{key:"_shiftByOrigin",value:function(e){for(var t=this.origin.x,r=this.origin.y,n=this.origin.z,i=e.length/4,o=0;oP&&(P=N)}this.neighbourListLength=27*P+1,this.withinRadii=function(t,r,n,i,l){var c=0,u=h(t,o),p=h(r,a),m=h(n,s),v=Math.max(0,u-1),x=Math.max(0,p-1),w=Math.max(0,m-1),S=Math.min(y-1,u+1),k=Math.min(_-1,p+1),P=Math.min(g-1,m+1);for(f=v;f<=S;++f){var T=f*b;for(C=x;C<=k;++C)for(var M=C*g,N=w;N<=P;++N)for(var I=R[d=T+M+N],O=I+A[d],L=I;La&&(a=n),o[e]=n*n}(function(){l=r.scaleFactor,u=t.dim,b=Math.min(5,2+Math.floor(s*l));var e=u[0]*u[1]*u[2];h=function(e,t,r){for(var n=$.allocateTyped(e,t),i=0;i=0;){if(o!==n&&o!==i&&F(o,e,t,r))return T=o,o;o=x[++a]}return T=-1,-1}function U(e,t){var r=w*e,n=w*t,i=S[r],o=S[r+1],a=S[r+2],s=S[r+3],f=O.x=S[n]-i,d=O.y=S[n+1]-o,g=O.z=S[n+2]-a,x=S[n+3],C=f*f+d*d+g*g,R=Math.sqrt(C),A=s*((s*s+R*R-x*x)/(2*s*R));O.normalize(),function(e,t){e.x=e.y=e.z=1,0!==t.x?e.x=(t.y+t.z)/-t.x:0!==t.y?e.y=(t.x+t.z)/-t.y:0!==t.z&&(e.z=(t.x+t.y)/-t.z)}(L,O),L.normalize(),B.crossVectors(O,L),B.normalize();var E=Math.sqrt(s*s-A*A);L.multiplyScalar(E),B.multiplyScalar(E),O.multiplyScalar(A),O.x+=i,O.y+=o,O.z+=a,T=-1;for(var P=b,M=0;M0&&CM[Z]&&(M[Z]=J,N[Z]=R[e]),h[Z]<0&&(h[Z]=-h[Z]);var te=Math.sqrt(Q),re=a/te,ne=K*re,ie=Y*re,oe=j*re;if(-1===V(ne+=r,ie+=n,oe+=i,e,-1)){var ae=a-te;ae=0;)e0){r=1/r;var n=3*e;f[n]*=r,f[n+1]*=r,f[n+2]*=r}}}(),console.timeEnd("ContactSurface.getVolume"),this.volTexMap=f,this.weightsMap=M,this.atomMap=N,this.volMap=h}}var zn=dr.Volume,Fn=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(){return a(this,i),n.apply(this,arguments)}return l(i,[{key:"_computeSurface",value:function(e,t,r,n){var i=new Dn(e,r,n);return i.build(),{volMap:new zn(Float32Array,this.numVoxels,t,1,i.volMap),volTexMap:new zn(Float32Array,this.numVoxels,t,3,i.volTexMap),atomMap:i.atomMap,atomWeightMap:new zn(Float32Array,this.numVoxels,t,1,i.weightsMap)}}}]),i}(In),Vn=l((function e(t,r){a(this,e),this.coord=new i.Pa4,this.coord.copy(t),this.radius=r,this.colorX=.99999,this.colorY=0,this.colorZ=0,this.atomType=0,this.srcAtom=null})),Un=function(){function e(t,r,n,o,s){a(this,e),this._numAtoms=t,this._atoms=r,this._vBoxMin=new i.Pa4,this._vBoxMax=new i.Pa4,this._vBoxMin.copy(n),this._vBoxMax.copy(o),this._probeRadius=s,this._atomsList=null,this._voxelList=null}return l(e,[{key:"createVoxels",value:function(){var e,t,r=0|this._numAtoms,n=this._atoms,i=this._vBoxMax.x-this._vBoxMin.x,o=this._vBoxMax.y-this._vBoxMin.y,a=this._vBoxMax.z-this._vBoxMin.z,s=ic?t:c,u+=t;var h=Math.floor(s/c);h<2&&(h=2),u/=r,this._numCells=h,this._aveRad=u,this._maxRad=c;var f=h,d=h*h,p=h*h*h,m=this._xScale=1/(this._vBoxMax.x-this._vBoxMin.x),v=this._yScale=1/(this._vBoxMax.y-this._vBoxMin.y),y=this._zScale=1/(this._vBoxMax.z-this._vBoxMin.z),_=0,g=m*h,x=v*h,b=y*h;for(l=0;l=0?E:0,k=k>=0?k:0,T=T=0?P:0;I<=N;I++)for(var O=k;O<=M;O++)for(var L=E;L<=T;L++){var B=L+O*f+I*d;if(this._voxelList[B]<0)A[2*e+0]=l,A[2*e+1]=-1,this._voxelList[B]=e,e++;else{var D=this._voxelList[B];this._voxelList[B]=e,A[2*e+0]=l,A[2*e+1]=D,e++}}}return this._atomsList=Int32Array.from(A),0}},{key:"destroyVoxels",value:function(){this._atomsList=null,this._voxelList=null,this._atoms=null,this._vertices=null,this._vBoxMin=null,this._vBoxMax=null}},{key:"forEachRelatedAtom",value:function(e,t){for(var r=Math.floor((e.x-this._vBoxMin.x)*this._numCells*this._xScale),n=Math.floor((e.y-this._vBoxMin.y)*this._numCells*this._yScale),i=Math.floor((e.z-this._vBoxMin.z)*this._numCells*this._zScale),o=r+n*this._numCells+i*this._numCells*this._numCells,a=this._atoms,s=this._voxelList[o];s>=0;s=this._atomsList[2*s+1])t(a[this._atomsList[2*s]])}},{key:"getClosestAtom",value:function(e){var t=null,r=Number.MAX_VALUE;return this.forEachRelatedAtom(e,(function(n){var i=e.distanceToSquared(n.coord);im)){var y=e.radius+i._probeRadius;(f=n-y*y)<0&&(f=-f),d=Math.exp(v*f),c+=t*d,u+=r*d,h+=p*d,o++}},_=0;_0&&(f=1/Math.sqrt(n),c*=f,u*=f,h*=f),r[_].x=c,r[_].y=u,r[_].z=h;return 0}},{key:"buildColors",value:function(e,t,r,n){for(var i=this,o=0,a=0,s=0,l=0,c=0,u=n*n,h=[],f=[],d=0,p=function(e){var t=o-e.coord.x,r=a-e.coord.y,n=s-e.coord.z,p=t*t+r*r+n*n;if(!(p>u)){var m=e.radius+i._probeRadius;(l=p-m*m)<0&&(l=-l),c=1/(.8+l),h.push([e.colorX,e.colorY,e.colorZ]),f.push(c),d+=c}},m=0;mo?c:o,l.x-cr.x&&(r.x=l.x+c),l.y+c>r.y&&(r.y=l.y+c),l.z+c>r.z&&(r.z=l.z+c)}t.x-=o,t.y-=o,t.z-=o,r.x+=o,r.y+=o,r.z+=o}},{key:"getCornerCoord",value:function(e,t,r,n,i,o,a){var s=1/(o-1),l=r*s,c=n*s,u=i*s;a.x=e.x*(1-l)+t.x*l,a.y=e.y*(1-c)+t.y*c,a.z=e.z*(1-u)+t.z*u}},{key:"buildEdgePoint",value:function(e,t,r,n,i,o){if(r[e]^r[t]){var a=(0-n.pointsValuesLinear[i+24+e])/(n.pointsValuesLinear[i+24+t]-n.pointsValuesLinear[i+24+e]),s=n.pointsValuesLinear[i+3*e+0],l=n.pointsValuesLinear[i+3*e+1],c=n.pointsValuesLinear[i+3*e+2],u=n.pointsValuesLinear[i+3*t+0],h=n.pointsValuesLinear[i+3*t+1],f=n.pointsValuesLinear[i+3*t+2];o.x=s*(1-a)+u*a,o.y=l*(1-a)+h*a,o.z=c*(1-a)+f*a}}},{key:"isTriangleVisible",value:function(e,t,r){var n=this.voxelWorld.getClosestAtom(e),i=this.voxelWorld.getClosestAtom(t),o=this.voxelWorld.getClosestAtom(r);return null!==n&&null!==i&&null!==o&&null!==n.srcAtom&&null!==i.srcAtom&&null!==o.srcAtom&&this.visibilitySelector.includesAtom(n.srcAtom)&&this.visibilitySelector.includesAtom(i.srcAtom)&&this.visibilitySelector.includesAtom(o.srcAtom)}},{key:"addTriangle",value:function(e,t,r){if(this.visibilitySelector&&!this.isTriangleVisible(e,t,r))return!0;var n=this.geoOut;if(n._numTriangles>=this.maxNumTriangles)return!1;var i=this.addVertexToGeo(n,e),o=this.addVertexToGeo(n,t),a=this.addVertexToGeo(n,r);if((i|o|a)<0)return!1;var s=3*n._numTriangles;return n._indices[s+0]=i,n._indices[s+1]=o,n._indices[s+2]=a,n._numTriangles++,!0}},{key:"buildGeoFromCorners",value:function(e,t,r,n,o,a){for(var s=e-1,l=e,c=e*e,u=new Array(12),h=0;h<12;h++)u[h]=new i.Pa4;for(var f=[],d=0;d<8;d++)f[d]=1;for(var p=new i.Pa4,m=0,v=0,y=0;yt.length/2||2*Object.keys(jn.ByAtomicNumber).length!==t.length)throw new Error("atomT.length should be equal Element.ByAtomicNumber.length * 2");return t[2*e]}},{key:"calculateGridCorners",value:function(e,t,r,n,o,a){for(var s=t*t,l=s*t,c=new i.Pa4,u=new i.Pa4,h=0;h=0;r=this.hashEntries[2*r+1]){var h=this.hashEntries[2*r+0];if(a.copy(e._vertices[h]),a.x-=t.x,a.y-=t.y,a.z-=t.z,a.x*a.x+a.y*a.y+a.z*a.z<1e-6)return h}if(e._numVertices>=this.maxNumVertices)return-1;var f=e._numVertices;if(e._vertices[f].copy(t),null!==this.vBoxMin&&null!==this.vBoxMax){if((r=this.getNewHashEntry())<0)return-1;var d=this.hashLines[u+1];this.hashLines[u+1]=r,this.hashEntries[2*r+0]=f,this.hashEntries[2*r+1]=d,this.hashLines[u+0]++}return e._numVertices++,f}},{key:"modifyExcludedFromGeo",value:function(e,t,r,n,i,o){for(var a,s,l=e*e,c=(e-1)/(n.x-r.x),u=(e-1)/(n.y-r.y),h=(e-1)/(n.z-r.z),f=2*t*(2*t),d=1/(e-1),p=0;p=0?y:0,g=g>=0?g:0,x=x<=e-1?x:e-1,b=b<=e-1?b:e-1,w=w<=e-1?w:e-1;for(var S=_=_>=0?_:0;S<=b;S++)for(var C=S*l,R=g;R<=w;R++)for(var A=R*e,E=y;E<=x;E++){a=C+A+E;var k=E*d,P=r.x*(1-k)+n.x*k;k=S*d;var T=r.y*(1-k)+n.y*k;k=R*d;var M=r.z*(1-k)+n.z*k,N=P-m.x,I=T-m.y,O=M-m.z,L=N*N+I*I+O*O;L0?(o[a]<0&&(o[a]=s),s>o[a]&&(o[a]=s)):s>o[a]&&(o[a]=s))}}return 0}},{key:"_innerBuild",value:function(){var e,t=1.2,r={posRad:this._posRad,colors:this._colors,atoms:this._opts.atoms};this.complex=this._opts.parent,this.atoms=r.atoms,this.meshResolution=this._opts.gridSpacing,this.atomRadiusScale=this._opts.radScale,this.colorMode=this._opts.colorMode,this.probeRadius=this._opts.probeRadius,this.useVertexColors=!0,this.excludeProbe=this._opts.excludeProbe,this.visibilitySelector=this._opts.visibilitySelector,this.geoOut=null,this.hashLines=null,this.hashEntries=null,this.numHashEtriesAllocated=0,this.numHashEntryIndex=0,this.maxNumVertices=0,this.maxNumTriangles=0;var n=new Array(this.atoms.length);this.convertToAtomsColored(r,n);var o=this.vBoxMin=new i.Pa4,a=this.vBoxMax=new i.Pa4;this.getBoundingBox(n,o,a);var s=this.marCubeResoultion=4*this.meshResolution,l=s,c=l*l*l,u=$.allocateTyped(Float32Array,c),h=this.probeRadius*this.atomRadiusScale;this.calculateGridCorners(u,l,o,a,n,h);var f=s-1,d=new En;if((e=d.create(f))<0)return e;var p=new i.Pa4;p.x=(a.x-o.x)/f,p.y=(a.y-o.y)/f,p.z=(a.z-o.z)/f;var m=this.getNumIntersectedCells(l,f,u,d),v=Math.floor(m*t),y=Math.floor(m*t*2);if(this.geoOut=new Gn(v,y,this.useVertexColors),(e=this.createVertexHash(v,y))<0)return e;var _=h;if(this.excludeProbe&&(_=.01),this.voxelWorld=new Un(n.length,n,o,a,_),this.voxelWorld.createVoxels(),e=this.buildGeoFromCorners(s,o,a,u,p,d),this.excludeProbe){if(this.modifyExcludedFromGeo(l,h,o,a,this.geoOut,u),this.geoOut._vertices=null,this.geoOut._colors=null,this.geoOut._indices=null,this.geoOut._normals=null,this.geoOut._numVertices=0,this.geoOut._numTriangles=0,this.geoOut=null,m=this.getNumIntersectedCells(l,f,u,d),v=Math.floor(m*t),y=Math.floor(m*t*2),this.geoOut=new Gn(v,y,this.useVertexColors),(e=this.createVertexHash(v,y))<0)return e;e=this.buildGeoFromCorners(l,o,a,u,p,d)}this.voxelWorld.buildNormals(this.geoOut._vertices.length,this.geoOut._vertices,this.geoOut._normals);var g=6.5;return this.excludeProbe&&(g-=1.5),this.useVertexColors&&this.voxelWorld.buildColors(this.geoOut._vertices.length,this.geoOut._vertices,this.geoOut._colors,g),this.voxelWorld.destroyVoxels(),this.voxelWorld=null,d.destroy(),e}}]),o}(An);var Wn=function(e){h(o,e);var t,r,n=(t=o,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function o(e,t){var r;a(this,o),(r=n.call(this))._opts=t,r.items=[],r.needsUpdate=!1;var s=-50,l=-50;switch(t.horizontalAlign){case"left":s=0;break;case"right":s=-100}switch(t.verticalAlign){case"top":l=-100;break;case"bottom":l=0}var c=new i.Pa4(t.dx||0,t.dy||0,t.dz||0);return r.userData={translation:"translate(".concat(s,"%, ").concat(l,"%)"),offset:c},r}return l(o,[{key:"setItem",value:function(e,t,r){var n=this._opts,o=this.items[e]||function(e,t){var r=document.createElement("div");if(r.className="label","string"==typeof e){var n=document.createElement("span");n.style.fontSize="150%";for(var o=e.split("\n"),a=0,s=o.length;a 0\r\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHTS ];\r\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHTS ];\r\n\t\tvarying vec3 vDirectionalShadowNormal[ NUM_DIR_LIGHTS ];\r\n\t#endif\r\n#endif\r\n\r\n#ifdef ATTR_COLOR\r\n attribute vec3 color;\r\n varying vec3 vColor;\r\n#endif\r\n\r\n#ifdef ATTR_COLOR2\r\n attribute vec3 color2;\r\n varying vec3 vColor2;\r\n attribute vec2 uv;\r\n #ifndef CYLINDER_SPRITE\r\n varying vec2 vUv;\r\n #endif\r\n#endif\r\n\r\n#ifdef INSTANCED_POS\r\n attribute vec4 offset;\r\n #ifdef SPHERE_SPRITE\r\n varying vec4 instOffset;\r\n varying vec4 spritePosEye;\r\n #endif\r\n#endif\r\n\r\n#ifdef INSTANCED_MATRIX\r\n attribute vec4 matVector1;\r\n attribute vec4 matVector2;\r\n attribute vec4 matVector3;\r\n attribute vec4 invmatVector1;\r\n attribute vec4 invmatVector2;\r\n attribute vec4 invmatVector3;\r\n\r\n #ifdef CYLINDER_SPRITE\r\n varying vec4 matVec1;\r\n varying vec4 matVec2;\r\n varying vec4 matVec3;\r\n varying vec4 invmatVec1;\r\n varying vec4 invmatVec2;\r\n varying vec4 invmatVec3;\r\n varying vec4 spritePosEye;\r\n #endif\r\n#endif\r\n\r\nuniform mat4 modelViewMatrix; // optional\r\nuniform mat4 projectionMatrix; // optional\r\nuniform mat3 normalMatrix; // optional\r\nuniform mat4 modelMatrix; // optional\r\n\r\n#ifdef DASHED_LINE\r\n attribute float lineDistance;\r\n varying float vLineDistance;\r\n#endif\r\n\r\n#ifdef THICK_LINE\r\n attribute vec3 direction;\r\n uniform mat4 projMatrixInv;\r\n uniform vec2 viewport;\r\n uniform float lineWidth;\r\n\r\n vec4 transform(vec4 coord){\r\n return projectionMatrix * modelViewMatrix * coord;\r\n }\r\n\r\n vec2 project(vec4 device){\r\n vec3 device_normal = device.xyz/device.w;\r\n vec2 clip_pos = (device_normal*0.5+0.5).xy;\r\n return clip_pos * viewport;\r\n }\r\n\r\n vec4 unproject(vec2 screen, float z, float w){\r\n vec2 clip_pos = screen/viewport;\r\n vec2 device_normal = clip_pos*2.0-1.0;\r\n return vec4(device_normal*w, z, w);\r\n }\r\n#endif\r\n\r\n\r\n/////////////////////////////////////////// Main ///////////////////////////////////////////////\r\nvoid main() {\r\n\r\n#ifdef ATTR_ALPHA_COLOR\r\n alphaCol = alphaColor;\r\n#endif\r\n\r\n#ifdef INSTANCED_MATRIX\r\n vec3 objectNormal = vec3(\r\n dot(normal, matVector1.xyz),\r\n dot(normal, matVector2.xyz),\r\n dot(normal, matVector3.xyz));\r\n#else\r\n vec3 objectNormal = vec3( normal );\r\n#endif\r\n\r\nvec3 transformedNormal = normalMatrix * objectNormal;\r\n\r\n#if !defined (SPHERE_SPRITE) && !defined (CYLINDER_SPRITE)\r\n vNormal = normalize(transformedNormal);\r\n#endif\r\n\r\n#ifdef NORMALS_TO_G_BUFFER\r\n viewNormal = normalize(mat3(modelViewMatrix)*objectNormal);\r\n#endif\r\n\r\n vec4 localPos = vec4(position.xyz, 1.0);\r\n vec4 worldPos = modelMatrix * localPos;\r\n vec4 mvPosition = modelViewMatrix * localPos;\r\n\r\n// make thick line offset\r\n#ifdef THICK_LINE\r\n // get screen pos\r\n vec4 dPos = transform(vec4(position.xyz, 1.0));\r\n vec2 sPos = project(dPos);\r\n // move pos forward\r\n vec3 position2 = position.xyz + direction.xyz * 0.5;\r\n // get screen offset pos\r\n vec4 dPos2 = transform(vec4(position2.xyz, 1.0));\r\n vec2 sPos2 = project(dPos2);\r\n // screen line direction\r\n vec2 sDir = normalize(sPos2 - sPos);\r\n // vertex offset (orthogonal to line direction)\r\n vec2 offset1 = vec2(-sDir.y, sDir.x);\r\n // move screen vertex\r\n vec2 newPos = sPos + offset1 * position.w * lineWidth;\r\n // get moved pos in view space\r\n vec4 dNewPos = unproject(newPos, dPos.z, dPos.w);\r\n mvPosition.xyz = (projMatrixInv * dNewPos).xyz;\r\n#endif // THICK_LINE\r\n\r\n#ifdef INSTANCED_POS\r\n #ifdef SPHERE_SPRITE\r\n instOffset = offset;\r\n\r\n vec4 posEye = modelViewMatrix * vec4( offset.xyz, 1.0 );\r\n float scale = length(modelViewMatrix[0]);\r\n mvPosition = posEye + vec4( position.xyz * offset.w * scale * INSTANCED_SPRITE_OVERSCALE, 0.0 );\r\n posEye.w = offset.w * scale;\r\n\r\n spritePosEye = posEye;\r\n #else\r\n localPos = vec4( offset.xyz + position.xyz * offset.w, 1.0 );\r\n worldPos = modelMatrix * localPos;\r\n mvPosition = modelViewMatrix * localPos;\r\n #endif\r\n#endif\r\n\r\n#ifdef INSTANCED_MATRIX\r\n #ifdef CYLINDER_SPRITE\r\n matVec1 = matVector1;\r\n matVec2 = matVector2;\r\n matVec3 = matVector3;\r\n invmatVec1 = invmatVector1;\r\n invmatVec2 = invmatVector2;\r\n invmatVec3 = invmatVector3;\r\n\r\n // calculate eye coords of cylinder endpoints\r\n vec4 v = vec4(0, -0.5, 0, 1);\r\n vec4 p1 = modelViewMatrix * vec4(dot(v, matVector1), dot(v, matVector2), dot(v, matVector3), 1.0);\r\n v.y = 0.5;\r\n vec4 p2 = modelViewMatrix * vec4(dot(v, matVector1), dot(v, matVector2), dot(v, matVector3), 1.0);\r\n\r\n // sprite is placed at the center of cylinder\r\n vec4 posEye;\r\n posEye.xyz = mix(p1.xyz, p2.xyz, 0.5);\r\n posEye.w = 1.0;\r\n spritePosEye = posEye;\r\n\r\n // cylinder radius in eye space\r\n float rad = length(modelViewMatrix[0]) * length(vec3(matVector1.x, matVector2.x, matVector3.x));\r\n vec2 spriteSize;\r\n #ifdef ORTHOGRAPHIC_CAMERA\r\n // In ortho projection we skip z coordinate\r\n // basic sprite size at screen plane (covers only cylinder axis)\r\n vec2 spriteSizeScreen = abs(p2.xy - p1.xy);\r\n\r\n spriteSize = vec2(1.0, 1.0) * INSTANCED_SPRITE_OVERSCALE * (spriteSizeScreen + 2.0 * rad);\r\n #else\r\n // basic sprite size at screen plane (covers only cylinder axis)\r\n vec2 spriteSizeScreen = abs(p2.xy / p2.z - p1.xy / p1.z);\r\n\r\n // full sprite size in eye coords\r\n float minZ = min(abs(p1.z), abs(p2.z));\r\n spriteSize = vec2(1.0, 1.0) * INSTANCED_SPRITE_OVERSCALE * abs(posEye.z) * (spriteSizeScreen + 2.0 * rad / minZ);\r\n #endif\r\n\r\n mvPosition = posEye + vec4( position.xy * 0.5 * spriteSize, 0, 0 );\r\n #else\r\n localPos = vec4(dot(localPos, matVector1), dot(localPos, matVector2), dot(localPos, matVector3), 1.0);\r\n worldPos = modelMatrix * localPos;\r\n mvPosition = modelViewMatrix * localPos;\r\n #endif\r\n#endif\r\n\r\n gl_Position = projectionMatrix * mvPosition;\r\n\r\n vWorldPosition = worldPos.xyz;\r\n vViewPosition = - mvPosition.xyz;\r\n\r\n#if defined(USE_LIGHTS) && defined(SHADOWMAP)\r\n\t#if NUM_DIR_LIGHTS > 0\r\n\t vec4 worldPosition;\r\n\t // see THREE.WebGLProgram.unrollLoops\r\n\t #pragma unroll_loop_start\r\n\t for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\r\n vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * vec4(vWorldPosition, 1.0);\r\n vDirectionalShadowNormal[ i ] = (directionalShadowMatrix[ i ] * (modelMatrix * vec4(objectNormal, 0.0))).xyz;\r\n\t }\r\n\t #pragma unroll_loop_end\r\n\t#endif\r\n#endif\r\n\r\n#ifdef ATTR_COLOR\r\n vColor = color.xyz;\r\n#endif\r\n\r\n#ifdef ATTR_COLOR2\r\n vColor2 = color2;\r\n #ifndef CYLINDER_SPRITE\r\n vUv = uv;\r\n #endif\r\n#endif\r\n\r\n#ifdef DASHED_LINE\r\n vLineDistance = lineDistance;\r\n#endif\r\n}\r\n",fragmentShader:t.precisionString()+"#if defined (NORMALS_TO_G_BUFFER)\r\n #define fragColor gl_FragData[0]\r\n#else\r\n #define fragColor gl_FragColor\r\n#endif\r\n\r\n#ifdef ATTR_ALPHA_COLOR\r\n varying float alphaCol;\r\n#endif\r\n\r\n#ifdef COLOR_FROM_POS\r\n uniform mat4 world2colorMatrix;\r\n#endif\r\n\r\n#if defined(USE_LIGHTS) && defined(SHADOWMAP)\r\n\t#if NUM_DIR_LIGHTS > 0\r\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHTS ];\r\n uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHTS ]; //only for sprites\r\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHTS ];\r\n\t\tvarying vec3 vDirectionalShadowNormal[ NUM_DIR_LIGHTS ];\r\n vec4 vDirLightWorldCoord[ NUM_DIR_LIGHTS ];\r\n vec3 vDirLightWorldNormal[ NUM_DIR_LIGHTS ];\r\n\r\n #ifdef SHADOWMAP_PCF_RAND\r\n // We use 4 instead uniform variable or define because this value is used in for(... i < value; ...) with\r\n // unroll_loop and unroll_loop has pattern:\r\n // /#pragma unroll_loop[\\s]+?for \\( int i \\= (\\d+)\\; i < (\\d+)\\; i \\+\\+ \\) \\{([\\s\\S]+?)(?=\\})\\}/g\r\n uniform vec2 samplesKernel[4]; // 4 is length of _samplesKernel which is defined in UberMaterial.js\r\n uniform sampler2D noiseTex;\r\n uniform vec2 noiseTexelSize;\r\n uniform vec2 srcTexelSize;\r\n uniform mat4 projectionMatrix;\r\n #endif\r\n\t#endif\r\n#endif\r\n\r\n#ifdef ATTR_COLOR\r\n varying vec3 vColor;\r\n#endif\r\n\r\n#ifdef ATTR_COLOR2\r\n varying vec3 vColor2;\r\n #ifndef CYLINDER_SPRITE\r\n varying vec2 vUv;\r\n #endif\r\n#endif\r\n\r\nuniform vec3 diffuse;\r\nuniform vec3 emissive;\r\nuniform vec3 specular;\r\nuniform float shininess;\r\nuniform vec3 fixedColor;\r\nuniform float opacity;\r\nuniform float zClipValue;\r\nuniform float clipPlaneValue;\r\n\r\n#ifdef NORMALS_TO_G_BUFFER\r\n varying vec3 viewNormal;\r\n#endif\r\n\r\n#define PI 3.14159265359\r\n#define RECIPROCAL_PI 0.31830988618\r\n#define saturate(a) clamp( a, 0.0, 1.0 )\r\n\r\n#ifdef USE_FOG\r\n uniform vec3 fogColor;\r\n uniform float fogAlpha;\r\n uniform float fogNear;\r\n uniform float fogFar;\r\n#endif\r\n\r\nvarying vec3 vWorldPosition; // world position of the pixel (invalid when INSTANCED_SPRITE is defined)\r\nvarying vec3 vViewPosition;\r\n\r\n#if !defined (SPHERE_SPRITE) && !defined (CYLINDER_SPRITE)\r\n varying vec3 vNormal;\r\n#endif\r\n\r\n/////////////////////////////////////////// ZSprites ////////////////////////////////////////////////\r\n#if defined (SPHERE_SPRITE) || defined (CYLINDER_SPRITE)\r\n uniform float nearPlaneValue;\r\n#endif\r\n\r\n#ifdef SPHERE_SPRITE\r\n varying vec4 spritePosEye;\r\n#endif\r\n\r\n#if defined(SPHERE_SPRITE) || defined(CYLINDER_SPRITE)\r\n uniform float zOffset;\r\n\r\n #if !defined(USE_LIGHTS) || !defined(SHADOWMAP) || !defined(SHADOWMAP_PCF_RAND) || !(NUM_DIR_LIGHTS > 0)\r\n uniform mat4 projectionMatrix;\r\n #endif\r\n\r\n float calcDepthForSprites(vec4 pixelPosEye, float zOffset, mat4 projMatrix) {\r\n vec4 pixelPosScreen = projMatrix * pixelPosEye;\r\n return 0.5 * (pixelPosScreen.z / pixelPosScreen.w + 1.0) + zOffset;\r\n }\r\n#endif\r\n\r\n#ifdef SPHERE_SPRITE\r\n varying vec4 instOffset;\r\n uniform mat4 modelMatrix;\r\n uniform mat4 modelViewMatrix;\r\n uniform mat4 invModelViewMatrix;\r\n uniform mat3 normalMatrix;\r\n\r\n\r\n bool intersect_ray_sphere(in vec3 origin, in vec3 ray, out vec3 point, out float frontFaced) {\r\n\r\n // intersect XZ-projected ray with circle\r\n float a = dot(ray, ray);\r\n float b = dot(ray, origin);\r\n float c = dot(origin, origin) - 1.0;\r\n float det = b * b - a * c;\r\n if (det < 0.0) return false;\r\n float t1 = (-b - sqrt(det)) / a;\r\n float t2 = (-b + sqrt(det)) / a;\r\n\r\n // calculate both intersection points\r\n vec3 p1 = origin + ray * t1;\r\n vec3 p2 = origin + ray * t2;\r\n\r\n // choose nearest point inside frustum\r\n #ifdef ORTHOGRAPHIC_CAMERA\r\n // orthografic camera is used for dirLight sources. So in it for all spheres the point with smaller 't' is visible\r\n // t1 is always smaller than t2 (from calculations)\r\n point = p1;\r\n frontFaced = 1.0;\r\n return true;\r\n #else\r\n // for perspective camera first intersection can be in front of near plane. If not intersection is p1 else - p2\r\n // t* = 0.0 corresponds to point of intersection near plane by the ray from camera to curPixel\r\n if (t1 >= 0.0) {\r\n point = p1;\r\n frontFaced = 1.0;\r\n return true;\r\n }\r\n if (t2 >= 0.0) {\r\n point = p2;\r\n frontFaced = -1.0;\r\n return true;\r\n }\r\n #endif\r\n\r\n return false;\r\n }\r\n\r\n bool get_sphere_point(in vec3 pixelPosEye, out vec3 point, out float frontFaced) {\r\n vec3 origin, ray;\r\n\r\n #ifdef ORTHOGRAPHIC_CAMERA\r\n // transform vector from sprite center to curPixel into sphere local coords\r\n origin = pixelPosEye.xyz - spritePosEye.xyz;\r\n origin = (invModelViewMatrix * vec4(origin, 0.0)).xyz / instOffset.w;\r\n\r\n // transform camera orientation vector into sphere local coords\r\n ray = (invModelViewMatrix * vec4(0.0, 0.0, -1.0, 0.0)).xyz;\r\n #else\r\n // find point of intersection near plane by the ray from camera to curPixel\r\n vec4 v = vec4(-(nearPlaneValue / pixelPosEye.z) * pixelPosEye, 1.0);\r\n\r\n // transform intersection point into sphere local coords\r\n v = invModelViewMatrix * v;\r\n origin = (v.xyz - instOffset.xyz) / instOffset.w;\r\n\r\n // transform vector from camera pos to curPixel into sphere local coords\r\n ray = (invModelViewMatrix * vec4(pixelPosEye, 0.0)).xyz;\r\n #endif\r\n ray = normalize(ray);\r\n\r\n return intersect_ray_sphere(origin, ray, point, frontFaced);\r\n }\r\n#endif\r\n\r\n#ifdef CYLINDER_SPRITE\r\n varying vec4 matVec1;\r\n varying vec4 matVec2;\r\n varying vec4 matVec3;\r\n varying vec4 invmatVec1;\r\n varying vec4 invmatVec2;\r\n varying vec4 invmatVec3;\r\n\r\n uniform mat4 modelMatrix;\r\n uniform mat4 modelViewMatrix;\r\n uniform mat4 invModelViewMatrix;\r\n uniform mat3 normalMatrix;\r\n\r\n varying vec4 spritePosEye;\r\n\r\n bool intersect_ray_cylinder(in vec3 origin, in vec3 ray, out vec3 point, out float frontFaced) {\r\n\r\n // intersect XZ-projected ray with circle\r\n float a = dot(ray.xz, ray.xz);\r\n float b = dot(ray.xz, origin.xz);\r\n float c = dot(origin.xz, origin.xz) - 1.0;\r\n float det = b * b - a * c;\r\n if (det < 0.0) return false;\r\n float t1 = (-b - sqrt(det)) / a;\r\n float t2 = (-b + sqrt(det)) / a;\r\n\r\n // calculate both intersection points\r\n vec3 p1 = origin + ray * t1;\r\n vec3 p2 = origin + ray * t2;\r\n\r\n float halfHeight = 0.5;\r\n\r\n // choose nearest point\r\n #ifdef ORTHOGRAPHIC_CAMERA\r\n // orthografic camera is used for dirLight sources. So in it for all cylinders the point with smaller 't' is visible\r\n // if it is not outside of cylinnder (t1 is always smaller than t2).\r\n if (p1.y >= -halfHeight && p1.y <= halfHeight) {\r\n point = p1;\r\n frontFaced = 1.0;\r\n return true;\r\n }\r\n if (p2.y >= -halfHeight && p2.y <= halfHeight) {\r\n point = p2;\r\n frontFaced = -1.0;\r\n return true;\r\n }\r\n #else\r\n // for perspective camera first intersection can be in front of near plane. If not intersection is p1 else - p2\r\n // t* = 0.0 corresponds to point of intersection near plane by the ray from camera to curPixel\r\n if (t1 >= 0.0 && p1.y >= -halfHeight && p1.y <= halfHeight) {\r\n point = p1;\r\n frontFaced = 1.0;\r\n return true;\r\n }\r\n if (t2 >= 0.0 && p2.y >= -halfHeight && p2.y <= halfHeight) {\r\n point = p2;\r\n frontFaced = -1.0;\r\n return true;\r\n }\r\n #endif\r\n\r\n return false;\r\n }\r\n\r\n bool get_cylinder_point(in vec3 pixelPosEye, out vec3 point, out float frontFaced) {\r\n vec3 origin, ray;\r\n vec4 v;\r\n\r\n #ifdef ORTHOGRAPHIC_CAMERA\r\n // transform vector from sprite center to curPixel into cylinder local coords\r\n v = invModelViewMatrix * vec4(pixelPosEye.xyz - spritePosEye.xyz, 0.0);\r\n origin = vec3(dot(v, invmatVec1), dot(v, invmatVec2), dot(v, invmatVec3));\r\n\r\n // transform camera orientation vector into cylinder local coords\r\n v = invModelViewMatrix * vec4(0.0, 0.0, -1.0, 0.0);\r\n ray = vec3(dot(v, invmatVec1), dot(v, invmatVec2), dot(v, invmatVec3));\r\n #else\r\n // find point of intersection near plane by the ray from camera to curPixel\r\n v = vec4(-(nearPlaneValue / pixelPosEye.z) * pixelPosEye, 1.0);\r\n\r\n // transform intersection point into cylinder local coords\r\n v = invModelViewMatrix * v;\r\n origin = vec3(dot(v, invmatVec1), dot(v, invmatVec2), dot(v, invmatVec3));\r\n\r\n // transform vector from camera pos to curPixel into cylinder local coords\r\n v = invModelViewMatrix * vec4(pixelPosEye, 0.0);\r\n ray = vec3(dot(v, invmatVec1), dot(v, invmatVec2), dot(v, invmatVec3));\r\n #endif\r\n ray = normalize(ray);\r\n\r\n return intersect_ray_cylinder(origin, ray, point, frontFaced);\r\n }\r\n#endif\r\n\r\n///////////////////////////////////// Pack and unpack ///////////////////////////////////////////////\r\nconst float PackUpscale = 256. / 255.; // fraction -> 0..1 (including 1)\r\nconst float UnpackDownscale = 255. / 256.; // 0..1 -> fraction (excluding 1)\r\n\r\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );\r\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\r\n\r\n\r\nconst float ShiftRight8 = 1. / 256.;\r\n\r\nvec4 packDepthToRGBA( const in float v ) {\r\n vec4 r = vec4( fract( v * PackFactors ), v );\r\n r.yzw -= r.xyz * ShiftRight8; // tidy overflow\r\n return r * PackUpscale;\r\n}\r\n\r\nfloat unpackRGBAToDepth( const in vec4 v ) {\r\n return dot( v, UnpackFactors );\r\n}\r\n\r\n////////////////////////////////////////// All Lighting /////////////////////////////////////////////////\r\n#ifdef TOON_SHADING\r\n #define LOW_TOON_BORDER 0.0\r\n #define MEDIUM_TOON_BORDER 0.7\r\n #define HIGH_TOON_BORDER 1.0\r\n\r\n #define MEDIUM_TOON_RANGE 0.5\r\n #define HIGH_TOON_RANGE 0.95\r\n#endif\r\n#if defined(USE_LIGHTS) && NUM_DIR_LIGHTS > 0\r\n struct ReflectedLight {\r\n vec3 directDiffuse;\r\n vec3 directSpecular;\r\n vec3 indirectDiffuse;\r\n };\r\n\r\n struct BlinnPhongMaterial {\r\n vec3 diffuseColor;\r\n vec3 specularColor;\r\n float specularShininess;\r\n };\r\n\r\n struct GeometricContext {\r\n vec3 normal;\r\n vec3 viewDir;\r\n };\r\n\r\n struct DirectionalLight {\r\n vec3 direction;\r\n vec3 color;\r\n };\r\n uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\r\n\r\n struct DirectionalLightShadow {\r\n vec2 shadowMapSize;\r\n float shadowBias;\r\n float shadowRadius;\r\n };\r\n uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHTS ];\r\n\r\n uniform vec3 ambientLightColor;\r\n\r\n /////////////////////////////////////////// Shadowmap ////////////////////////////////////////////////\r\n\r\n #if defined(SHADOWMAP)\r\n \tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\r\n \t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\r\n \t}\r\n\r\n float getShadow( sampler2D shadowMap, DirectionalLightShadow dirLight, vec4 shadowCoord, vec3 vViewPosition, vec3 vNormal ) {\r\n \t float shadow = 0.0;\r\n\r\n // When shadows for sprites will appear use here for them normals as it done for G-buffer\r\n shadowCoord.xyz += dirLight.shadowBias * vNormal;\r\n shadowCoord.xyz /= shadowCoord.w;\r\n\r\n bvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );\r\n bool inFrustum = all( inFrustumVec );\r\n bvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );\r\n bool frustumTest = all( frustumTestVec );\r\n\r\n if ( frustumTest ) {\r\n #ifdef SHADOWMAP_BASIC\r\n \t shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\r\n \t#endif\r\n\r\n \t#ifdef SHADOWMAP_PCF_SHARP\r\n \t vec2 texelSize = vec2( 1.0 ) / dirLight.shadowMapSize;\r\n\r\n float dx0 = - texelSize.x * dirLight.shadowRadius;\r\n float dy0 = - texelSize.y * dirLight.shadowRadius;\r\n float dx1 = + texelSize.x * dirLight.shadowRadius;\r\n float dy1 = + texelSize.y * dirLight.shadowRadius;\r\n\r\n shadow = (\r\n \ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\r\n \ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\r\n \ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\r\n \ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\r\n \ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\r\n \ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\r\n \ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\r\n \ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\r\n \ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\r\n ) * ( 1.0 / 9.0 );\r\n #endif\r\n\r\n #ifdef SHADOWMAP_PCF_RAND\r\n vec2 texelSize = vec2( 1.0 ) / dirLight.shadowMapSize;\r\n\r\n vec4 vUv = ((projectionMatrix * vec4(vViewPosition, 1.0)) + 1.0) / 2.0;\r\n vec2 vUvNoise = vUv.xy / srcTexelSize * noiseTexelSize;\r\n\r\n vec2 noiseVec = normalize(texture2D(noiseTex, vUvNoise).rg);\r\n mat2 mNoise = mat2(noiseVec.x, noiseVec.y, -noiseVec.y, noiseVec.x);\r\n\r\n vec2 offset;\r\n #pragma unroll_loop_start\r\n for ( int i = 0; i < 4; i ++ ) { // 4 is length of _samplesKernel which is defined in UberMaterial.js\r\n offset = mNoise * ( normalize( samplesKernel[ i ]) * texelSize * dirLight.shadowRadius );\r\n shadow += texture2DCompare( shadowMap, shadowCoord.xy + offset, shadowCoord.z );\r\n }\r\n #pragma unroll_loop_end\r\n shadow /= float( 4 ); // 4 is length of _samplesKernel which is defined in UberMaterial.js\r\n #endif\r\n }\r\n return shadow;//(shadow != 1.0) ? 0.5 : 1.0;//vec4(shadow, shadow, shadow, 1.0);\r\n }\r\n #endif\r\n\r\n /////////////////////////////////////////// Lighting /////////////////////////////////////////////////\r\n\r\n vec3 BRDF_Diffuse_Lambert( const in vec3 diffuseColor ) {\r\n return RECIPROCAL_PI * diffuseColor;\r\n } // validated\r\n\r\n vec3 F_Schlick( const in vec3 specularColor, const in float dotLH ) {\r\n // Original approximation by Christophe Schlick '94\r\n //;float fresnel = pow( 1.0 - dotLH, 5.0 );\r\n // Optimized variant (presented by Epic at SIGGRAPH '13)\r\n float fresnel = exp2( ( -5.55473 * dotLH - 6.98316 ) * dotLH );\r\n return ( 1.0 - specularColor ) * fresnel + specularColor;\r\n } // validated\r\n\r\n float G_BlinnPhong_Implicit( /* const in float dotNL, const in float dotNV */ ) {\r\n // geometry term is (n dot l)(n dot v) / 4(n dot l)(n dot v)\r\n return 0.25;\r\n }\r\n\r\n float D_BlinnPhong( const in float shininess, const in float dotNH ) {\r\n return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\r\n }\r\n\r\n vec3 BRDF_Specular_BlinnPhong( const in DirectionalLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float shininess ) {\r\n vec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\r\n float dotNH = saturate(dot( geometry.normal, halfDir ));\r\n float dotLH = saturate(dot( incidentLight.direction, halfDir ));\r\n\r\n vec3 F = F_Schlick( specularColor, dotLH );\r\n float G = G_BlinnPhong_Implicit( /* dotNL, dotNV */ );\r\n float D = D_BlinnPhong( shininess, dotNH );\r\n\r\n return F * ( G * D );\r\n } // validated\r\n\r\n void RE_Direct_BlinnPhong( const in DirectionalLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight, float penumbra ) {\r\n\r\n float dotNL = saturate( dot( geometry.normal, directLight.direction ));\r\n #ifdef TOON_SHADING\r\n if(dotNL < MEDIUM_TOON_RANGE){\r\n dotNL = LOW_TOON_BORDER;\r\n }\r\n else if(dotNL < HIGH_TOON_RANGE){\r\n dotNL = MEDIUM_TOON_BORDER;\r\n }\r\n else{\r\n dotNL = HIGH_TOON_BORDER;\r\n }\r\n #endif\r\n\r\n vec3 irradiance = dotNL * directLight.color * PI;\r\n reflectedLight.directDiffuse += penumbra * irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\r\n reflectedLight.directSpecular += penumbra * irradiance * BRDF_Specular_BlinnPhong( directLight, geometry, material.specularColor, material.specularShininess );\r\n }\r\n\r\n void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\r\n reflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\r\n }\r\n\r\n vec3 calcLighting(const in GeometricContext geometry, const in BlinnPhongMaterial material, vec3 vViewPosition) {\r\n ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ));\r\n vec3 irradiance = ambientLightColor * PI;\r\n\r\n float shadowMask = 1.0;\r\n // see THREE.WebGLProgram.unrollLoops\r\n \t#pragma unroll_loop_start\r\n \t for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\r\n \t #ifdef SHADOWMAP\r\n \t shadowMask = getShadow( directionalShadowMap[ i ], directionalLightShadows[ i ], vDirLightWorldCoord[ i ], vViewPosition, vDirLightWorldNormal[ i ] );\r\n #endif\r\n\r\n \t\t if ( shadowMask > 0.0 ) RE_Direct_BlinnPhong( directionalLights[ i ], geometry, material, reflectedLight, shadowMask );\r\n \t\t}\r\n \t\t#pragma unroll_loop_end\r\n\r\n RE_IndirectDiffuse_BlinnPhong(irradiance, material, reflectedLight);\r\n\r\n return saturate(reflectedLight.indirectDiffuse + reflectedLight.directDiffuse + reflectedLight.directSpecular);\r\n }\r\n#endif\r\n\r\n/////////////////////////////////////////// Dashed Line ///////////////////////////////////////////////\r\n#ifdef DASHED_LINE\r\n uniform float dashedLineSize;\r\n uniform float dashedLinePeriod;\r\n varying float vLineDistance;\r\n#endif\r\n\r\n/////////////////////////////////////////// Main ///////////////////////////////////////////////\r\nvoid main() {\r\n\r\n#ifdef CLIP_PLANE\r\n if (vViewPosition.z < clipPlaneValue) discard;\r\n#endif\r\n\r\n#ifdef ZCLIP\r\n if (vViewPosition.z < zClipValue) discard;\r\n#endif\r\n\r\n#if defined(USE_LIGHTS) && defined(SHADOWMAP)\r\n #if NUM_DIR_LIGHTS > 0\r\n // see THREE.WebGLProgram.unrollLoops\r\n #pragma unroll_loop_start\r\n for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\r\n vDirLightWorldCoord[ i ] = vDirectionalShadowCoord[ i ];\r\n vDirLightWorldNormal[ i ] = vDirectionalShadowNormal[ i ];\r\n }\r\n #pragma unroll_loop_end\r\n #endif\r\n#endif\r\n\r\n vec4 pixelPosWorld = vec4(vWorldPosition, 1.0);\r\n vec4 pixelPosEye;\r\n\r\n#ifdef SPHERE_SPRITE\r\n\r\n vec3 viewNormalSprites;\r\n float frontFaced = 1.0;\r\n vec3 normal;\r\n\r\n/* quick-and-dirty method\r\n normal.xy = ' + INSTANCED_SPRITE_OVERSCALE + ' * (2.0 * vUv - 1.0);\r\n float r2 = dot(normal.xy, normal.xy);\r\n if (r2 > 1.0) discard;\r\n float normalZ = sqrt(1.0 - r2);\r\n normal.z = normalZ;\r\n normal = normal * ( -1.0 + 2.0 * float( gl_FrontFacing ) );\r\n pixelPosEye = vec4(spritePosEye.xyz, 1.0);\r\n pixelPosEye.z += spritePosEye.w * normalZ;\r\n*/\r\n\r\n // ray-trace sphere surface\r\n {\r\n vec3 p;\r\n if (!get_sphere_point(-vViewPosition, p, frontFaced)) discard;\r\n vec4 v = vec4(instOffset.xyz + p * instOffset.w, 1.0);\r\n pixelPosWorld = modelMatrix * v;\r\n pixelPosEye = modelViewMatrix * v;\r\n normal = normalize(normalMatrix * p);\r\n #ifdef NORMALS_TO_G_BUFFER\r\n viewNormalSprites = normalize(mat3(modelViewMatrix)*p);\r\n #endif\r\n\r\n #if defined(USE_LIGHTS) && defined(SHADOWMAP)\r\n #if NUM_DIR_LIGHTS > 0\r\n // see THREE.WebGLProgram.unrollLoops\r\n #pragma unroll_loop_start\r\n for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\r\n vDirLightWorldCoord[ i ] = directionalShadowMatrix[ i ] * pixelPosWorld;\r\n vDirLightWorldNormal[ i ] = (directionalShadowMatrix[ i ] * (modelMatrix * vec4(p, 0.0))).xyz;\r\n }\r\n #pragma unroll_loop_end\r\n #endif\r\n #endif\r\n }\r\n#endif\r\n\r\n#ifdef CYLINDER_SPRITE\r\n vec3 normal;\r\n vec3 viewNormalSprites;\r\n float frontFaced = 1.0;\r\n float cylinderY = 0.0;\r\n\r\n // ray-trace cylinder surface\r\n {\r\n vec3 p;\r\n if (!get_cylinder_point(-vViewPosition, p, frontFaced)) discard;\r\n\r\n cylinderY = 0.5 * (p.y + 1.0);\r\n\r\n vec4 v = vec4(p, 1.0);\r\n v = vec4(dot(v, matVec1), dot(v, matVec2), dot(v, matVec3), 1.0);\r\n pixelPosWorld = modelMatrix * v;\r\n pixelPosEye = modelViewMatrix * v;\r\n\r\n vec3 localNormal = normalize(vec3(p.x, 0.0, p.z));\r\n normal = vec3(\r\n dot(localNormal, matVec1.xyz),\r\n dot(localNormal, matVec2.xyz),\r\n dot(localNormal, matVec3.xyz));\r\n #ifdef NORMALS_TO_G_BUFFER\r\n viewNormalSprites = normalize(mat3(modelViewMatrix)*normal);\r\n #endif\r\n\r\n #if defined(USE_LIGHTS) && defined(SHADOWMAP)\r\n #if NUM_DIR_LIGHTS > 0\r\n // see THREE.WebGLProgram.unrollLoops\r\n #pragma unroll_loop_start\r\n for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\r\n vDirLightWorldCoord[ i ] = directionalShadowMatrix[ i ] * pixelPosWorld;\r\n vDirLightWorldNormal[ i ] = (directionalShadowMatrix[ i ] * (modelMatrix * vec4(normal, 0.0))).xyz;\r\n }\r\n #pragma unroll_loop_end\r\n #endif\r\n #endif\r\n\r\n normal = normalize(normalMatrix * normal);\r\n }\r\n#endif\r\n\r\n #ifdef ATTR_COLOR\r\n vec3 vertexColor = vColor;\r\n #else\r\n vec3 vertexColor = vec3(1.0, 1.0, 1.0);\r\n #endif\r\n\r\n #ifdef ATTR_COLOR2\r\n #ifdef CYLINDER_SPRITE\r\n float colorCoef = cylinderY; // cylinder parameter is calculated from ray-tracing\r\n #else\r\n float colorCoef = vUv.y; // cylinder parameter is interpolated as tex coord\r\n #endif\r\n // choose either color or color2\r\n vertexColor = mix(vColor2, vColor, step(0.5, colorCoef));\r\n #endif\r\n\r\n // negative red component is a special condition\r\n if (vertexColor.x < 0.0) discard;\r\n\r\n #ifdef DASHED_LINE\r\n if ( mod( vLineDistance, dashedLinePeriod ) > dashedLineSize ) discard;\r\n #endif\r\n\r\n // transparency prepass writes only z, so we don't need to calc the color\r\n #ifdef PREPASS_TRANSP\r\n fragColor = vec4(1.0, 1.0, 1.0, 1.0);\r\n #if defined(SPHERE_SPRITE) || defined(CYLINDER_SPRITE)\r\n gl_FragDepthEXT = calcDepthForSprites(pixelPosEye, zOffset, projectionMatrix);\r\n #endif\r\n return;\r\n #endif\r\n\r\n float totalOpacity = opacity;\r\n\r\n #ifdef ATTR_ALPHA_COLOR\r\n totalOpacity *= alphaCol;\r\n #endif\r\n\r\n // discard fully transparent pixels\r\n if (totalOpacity == 0.0) discard;\r\n\r\n #ifdef FAKE_OPACITY\r\n // discard pixels in checker pattern\r\n vec2 dm_coord = floor(gl_FragCoord.xy);\r\n dm_coord = fract(dm_coord * 0.5);\r\n if (totalOpacity < 1.0 && (dm_coord.x < 0.5 ^^ dm_coord.y < 0.5)) discard;\r\n vec4 diffuseColor = vec4(diffuse, 1.0);\r\n #else\r\n vec4 diffuseColor = vec4(diffuse, totalOpacity);\r\n #endif\r\n\r\n float flipNormal;\r\n #if !defined (SPHERE_SPRITE) && !defined (CYLINDER_SPRITE)\r\n flipNormal = 1.0;\r\n #ifdef DOUBLE_SIDED\r\n flipNormal = float( gl_FrontFacing );\r\n #endif\r\n vec3 normal = normalize( vNormal ) * flipNormal;\r\n #endif\r\n\r\n diffuseColor.rgb *= vertexColor;\r\n\r\n #if defined(SPHERE_SPRITE) || defined(CYLINDER_SPRITE)\r\n gl_FragDepthEXT = calcDepthForSprites(pixelPosEye, zOffset, projectionMatrix);\r\n #endif\r\n\r\n #ifdef NORMALS_TO_G_BUFFER\r\n #if defined (SPHERE_SPRITE) || defined (CYLINDER_SPRITE)\r\n vec3 viewNormaInColor = viewNormalSprites;\r\n #else\r\n vec3 viewNormaInColor = viewNormal;\r\n float frontFaced = float( gl_FrontFacing );\r\n #endif\r\n // [-1, 1] -> [0, 1]\r\n viewNormaInColor = 0.5 * viewNormaInColor + 0.5;\r\n gl_FragData[1] = vec4(viewNormaInColor, frontFaced);\r\n #endif\r\n\r\n #if defined(USE_LIGHTS) && NUM_DIR_LIGHTS > 0\r\n vec3 viewDir;\r\n #if defined(SPHERE_SPRITE) || defined(CYLINDER_SPRITE)\r\n viewDir = -pixelPosEye.xyz;\r\n #else\r\n viewDir = vViewPosition;\r\n #endif\r\n GeometricContext geometry = GeometricContext(normal, normalize( viewDir ));\r\n BlinnPhongMaterial material = BlinnPhongMaterial(diffuseColor.rgb, specular, shininess);\r\n vec3 outgoingLight = calcLighting(geometry, material, viewDir);\r\n #else\r\n vec3 outgoingLight = diffuseColor.rgb;\r\n #endif\r\n\r\n #ifdef COLOR_FROM_DEPTH\r\n float depth = 0.0;\r\n #if defined(SPHERE_SPRITE) || defined(CYLINDER_SPRITE)\r\n gl_FragDepthEXT = calcDepthForSprites(pixelPosEye, zOffset, projectionMatrix);\r\n depth = gl_FragDepthEXT;\r\n #else\r\n depth = gl_FragCoord.z;\r\n #endif\r\n fragColor = packDepthToRGBA(depth);\r\n return;\r\n #endif\r\n\r\n #ifdef COLOR_FROM_POS\r\n fragColor = world2colorMatrix * pixelPosWorld;\r\n #else\r\n #ifdef OVERRIDE_COLOR\r\n fragColor = vec4(fixedColor, diffuseColor.a);\r\n #else\r\n fragColor = vec4(outgoingLight, diffuseColor.a);//vec4(vNormal, 1.0);\r\n #endif\r\n\r\n #ifdef USE_FOG\r\n float viewDistance;\r\n #if defined(SPHERE_SPRITE) || defined(CYLINDER_SPRITE)\r\n viewDistance = abs(pixelPosEye.z);\r\n #else\r\n viewDistance = vViewPosition.z;\r\n #endif\r\n float fogFactor = smoothstep( fogNear, fogFar, viewDistance) * fogAlpha;\r\n #ifdef FOG_TRANSPARENT\r\n fragColor.a = fragColor.a * (1.0 - fogFactor);\r\n #else\r\n fragColor.rgb = mix( fragColor.rgb, fogColor, fogFactor );\r\n #endif\r\n #endif\r\n\r\n #endif\r\n}\r\n",lights:!0,fog:!0,side:i.ehD},e)),t}return l(o,[{key:"precisionString",value:function(){var e=Xn.precision;return"precision ".concat(e," float;\n")+"precision ".concat(e," int;\n\n")}},{key:"copy",value:function(e){return Ye(d(o.prototype),"copy",this).call(this,e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=i.rDY.clone(e.uniforms),this.defines=ni({},e.defines),this.extensions=e.extensions,this.fog=e.fog,this.instancedPos=e.instancedPos,this.instancedMatrix=e.instancedMatrix,this.attrColor=e.attrColor,this.attrColor2=e.attrColor2,this.attrAlphaColor=e.attrAlphaColor,this.overrideColor=e.overrideColor,this.sphereSprite=e.sphereSprite,this.cylinderSprite=e.cylinderSprite,this.zClip=e.zClip,this.clipPlane=e.clipPlane,this.fakeOpacity=e.fakeOpacity,this.colorFromPos=e.colorFromPos,this.shadowmap=e.shadowmap,this.shadowmapType=e.shadowmapType,this.colorFromDepth=e.colorFromDepth,this.orthoCam=e.orthoCam,this.prepassTransparancy=e.prepassTransparancy,this.dashedLine=e.dashedLine,this.thickLine=e.thickLine,this.fogTransparent=e.fogTransparent,this.normalsToGBuffer=e.normalsToGBuffer,this.toonShading=e.toonShading,this.uberOptions.copy(e.uberOptions),this}},{key:"createInstance",value:function(){var e=new o;return e.copy(this),e.uberOptions=Object.create(this.uberOptions),e}},{key:"setValues",value:function(e){if(void 0!==e){Ye(d(o.prototype),"setValues",this).call(this,e);var t={},r={};this.fog&&(t.USE_FOG=1),this.instancedPos&&(t.INSTANCED_POS=1),this.instancedMatrix&&(t.INSTANCED_MATRIX=1),this.attrColor&&(t.ATTR_COLOR=1),this.attrColor2&&(t.ATTR_COLOR2=1),this.attrAlphaColor&&(t.ATTR_ALPHA_COLOR=1),this.overrideColor&&(t.OVERRIDE_COLOR=1),this.sphereSprite&&(t.SPHERE_SPRITE=1,r.fragDepth=1),this.cylinderSprite&&(t.CYLINDER_SPRITE=1,r.fragDepth=1),this.zClip&&(t.ZCLIP=1),this.clipPlane&&(t.CLIP_PLANE=1),this.fakeOpacity&&(t.FAKE_OPACITY=1),this.lights&&(t.USE_LIGHTS=1),this.colorFromPos&&(t.COLOR_FROM_POS=1),this.shadowmap&&(t.SHADOWMAP=1,"pcf"===this.shadowmapType?t.SHADOWMAP_PCF_SHARP=1:"random"===this.shadowmapType?t.SHADOWMAP_PCF_RAND=1:t.SHADOWMAP_BASIC=1),this.colorFromDepth&&(t.COLOR_FROM_DEPTH=1),this.orthoCam&&(t.ORTHOGRAPHIC_CAMERA=1),this.prepassTransparancy&&(t.PREPASS_TRANSP=1),this.dashedLine&&(t.DASHED_LINE=1),this.thickLine&&(t.THICK_LINE=1),this.fogTransparent&&(t.FOG_TRANSPARENT=1),this.normalsToGBuffer&&(r.drawBuffers=1,t.NORMALS_TO_G_BUFFER=1),this.toonShading&&(t.TOON_SHADING=1),this.defines=t,this.extensions=r}}},{key:"setUberOptions",value:function(e){if(void 0!==e)for(var t in e)e.hasOwnProperty(t)&&(this.uberOptions[t]instanceof i.Ilk?this.uberOptions[t]=e[t].clone():this.uberOptions[t]=e[t])}},{key:"clone",value:function(e){return e?this.createInstance():i.F5T.prototype.clone.call(this)}},{key:"updateUniforms",value:function(){var e=this;ai.forEach((function(t){e.uniforms.hasOwnProperty(t)&&(e.uberOptions[t]instanceof i.Ilk||e.uberOptions[t]instanceof i.yGw?e.uniforms[t].value=e.uberOptions[t].clone():e.uniforms[t].value=e.uberOptions[t])}))}}]),o}(i.FIo);function ci(e){var t=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(){var e;a(this,i);for(var t=arguments.length,r=new Array(t),o=0;o=0;--t)this.remove(e[t]);for(var r=this.geometry,i=r.items,o=r.userData,a=0,s=i.length;a0?s:[new i.yGw];for(var u=l._createMeshes(e),h=0,f=u.length;h>16&255,r=e>>8&255,n=255&e;return.2126*t+.7152*r+.0722*n>127?(t=3*t/10,r=3*r/10,n=3*n/10):(t=255-3*(255-t)/10,r=255-3*(255-r)/10,n=255-3*(255-n)/10),t<<16|r<<8|n},inverse:function(e){return 255-(e>>16&255)<<16|255-(e>>8&255)<<8|255-(255&e)}};function Oi(e,t){var r;if(Ii.hasOwnProperty(t))r=$.hexColor(Ii[t](e));else{var n=parseInt(t,16);r=!Number.isNaN(n)&&t.toLowerCase().startsWith("0x")?$.hexColor(n):"#000000"}return r}var Li={serial:function(e){return e.serial},name:function(e){return e.getVisualName()},elem:function(e){return e.element.name},residue:function(e){return e.residue.getType().getName()},sequence:function(e){return e.residue.getSequence()},chain:function(e){return e.residue.getChain().getName()},hetatm:function(e){return e.isHet()},water:function(e){return"HOH"===e.residue.getType().getName()||"WAT"===e.residue.getType().getName()}},Bi=function(e,t){return t.replace(/\{\{(\s*\w+\s*)\}\}/g,(function(t){var r=t.replace(/\s+/g,"");return r=r.substring(2,r.length-2).toLowerCase(),Li.hasOwnProperty(r)?Li[r](e):"null"}))},Di=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(){return a(this,i),n.apply(this,arguments)}return l(i,[{key:"_makeGeoArgs",value:function(){var e=this._mode.getLabelOpts();return[this._selection.chunks.length,e]}},{key:"_build",value:function(){for(var e=this._mode.getLabelOpts(),t=this._selection.chunks,r=this._selection,n=r.atoms,i=r.parent,o=this._colorer,a=this._geo,s=0,l=t.length;st-1&&(e=r-e),e},e=function(){function e(e,t){if(this.array=e.slice(0),this.length=this.array.length,!(this.clipHelper={clamp:this.clipHelperClamp,zero:this.clipHelperZero,periodic:this.clipHelperPeriodic,mirror:this.clipHelperMirror}[t.clip]))throw"Invalid clip: "+t.clip}return e.prototype.getClippedInput=function(e){return 0<=e&&e=o;i<=o?r++:r--)n+=this.kernel(e-r)*this.getClippedInput(r);return n},t}(e),f=function(e,t){var r,n,i,o;for(o=[],n=0,i=e.length;nl;0<=l?c++:c--)t.push(new p(f(e,c),r));return t}(),function(e){var t,r,n,i;for(i=[],r=0,n=m.length;ri&&e[t-1]._isValid?t-1:t}function s(t){return t2&&void 0!==arguments[2]&&arguments[2],o=arguments.length>3&&void 0!==arguments[3]&&arguments[3],c=i.getResidueColor(e,r);l[s]=e._index,a.setItem(s,t,n,o),a.setColor(s++,c)})),this._chunksIdc=l,a.finalize()}},{key:"updateToFrame",value:function(e){var t=this._selection.parent,r=this._mode,n=this._colorer,i=r.getTension(),o=this._geo,a=e.getResidues(),s=0,l=e.needsColorUpdate(n);ro(this._selection.subdivs,a,this._segmentsHeight,i,r,(function(e,r){o.setItem(s,r),l&&o.setColor(s,n.getResidueColor(e,t)),s++})),o.finalize()}}]),i}(Hi);var io=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(){return a(this,i),n.apply(this,arguments)}return l(i,[{key:"_makeGeoArgs",value:function(){for(var e=this._selection.subdivs,t=0,r=0,n=e.length;r1&&0!==k&&(h.lerpVectors(x,b,so/C),f.lerpVectors(x,b,1-so/C)),k*=so,h.addScaledVector(R,k),f.addScaledVector(R,k),s.setItem(d,h,f),s.setColor(d++,a.getAtomColor(_,n),a.getAtomColor(g,n))}}s.finalize(),this._chunksIdc=p}},{key:"updateToFrame",value:function(e){for(var t=this._selection.chunks,r=this._selection.bonds,n=this._mode,o=this._colorer,a=this._geo,s=n.drawMultiorderBonds(),l=n.showAromaticLoops(),c=new i.Pa4,u=new i.Pa4,h=new i.Pa4,f=0,d=e.needsColorUpdate(o),p=0,m=t.length;p1&&0!==E&&(u.lerpVectors(g,x,so/S),h.lerpVectors(g,x,1-so/S)),E*=so,u.addScaledVector(C,E),h.addScaledVector(C,E),a.setItem(f,u,h),d&&a.setColor(f,e.getAtomColor(o,y),e.getAtomColor(o,_)),f++}}a.finalize()}}]),o}(oo),co={AtomsSphereGroup:Pi,AtomsSurfaceGroup:Ti,AtomsSASSESGroupStub:Mi,AtomsTextGroup:Di,AromaticTorusGroup:Gi,AromaticLinesGroup:ji,NucleicCylindersGroup:Yi,NucleicSpheresGroup:qi,ResiduesSubseqGroup:no,ResiduesTraceGroup:io,BondsCylinderGroup:ao,BondsLinesGroup:lo};var uo=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(e,t,r,o,s,l,u,h){var f;a(this,i);var d=c(f=n.call(this));f._complex=r,f._mode=s;var p=r.getAtoms(),m=r.getTransforms();return r.forEachComponent((function(n){var i=[],a=0;if(n.forEachAtom((function(e){d._checkAtom(e,u)&&(i[a++]=e.index)})),0!==a){var c=new e(t,{atoms:p,chunks:i,parent:r},o,s,m,l,h);c._component=n,d.add(c)}})),f}return l(i,[{key:"_checkAtom",value:function(e,t){return e.mask&t}},{key:"getSubset",value:function(e,t){for(var r=[],n=this.children,i=0,o=0,a=n.length;o0&&(c[f++]=e)}));var d=new e(t,{cycles:c,atoms:m,chunks:i,parent:r},o,s,v,l,h);d._component=n,p.add(d)})),d):f(d)}return l(i,[{key:"getSubset",value:function(e,t){for(var r=[],n=this.children,i=0,o=0,a=n.length;o0&&l.add(f)}return l}}]),e}();function wo(){return{lineWidth:this.opts.lineWidth}}Nr(bo.prototype),bo.prototype.id="__",bo.prototype.depGroups=[];var So=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(e){var t;a(this,i),(t=n.call(this,e)).depGroups=t.depGroups.slice(0);for(var r=t.depGroups,o=0,s=r.length;o1&&void 0!==arguments[1]&&arguments[1],r=this.elementColors[e];return void 0!==r||t?r:this.defaultElementColor}},{key:"getResidueColor",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=this.residueColors[e];return void 0!==r||t?r:this.defaultResidueColor}},{key:"getChainColor",value:function(e){var t=e.charCodeAt(0);return t=(31&(t<0?0:t>=256?t-256:t))%this.chainColors.length,this.chainColors[t]}},{key:"getSecondaryColor",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=this.secondaryColors[e];return void 0!==r||t?r:this.defaultSecondaryColor}},{key:"getSequentialColor",value:function(e){var t=this.colors,r=t.length;return e<0?t[e%r+r]:t[e%r]}},{key:"getGradientColor",value:function(e,t){var r=this.gradients[t];if(!r)return this.defaultNamedColor;var n,i,o,a,s=r.length,l=e*(s-1),c=Math.floor(l),u=Vo(c+1,0,s-1);return(a=1-(o=l-(c=Vo(c,0,s-1))))*((n=r[c])>>16&255)+o*((i=r[u])>>16&255)<<16|a*(n>>8&255)+o*(i>>8&255)<<8|a*(255&n)+o*(255&i)}},{key:"getNamedColor",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=this.namedColors[e];return void 0!==r||t?r:this.defaultNamedColor}}]),e}();(0,n.assign)(Uo.prototype,{colors:[16777215,16711680,65280,255,8421504],minRangeColor:0,midRangeColor:8355711,maxRangeColor:16777215,defaultElementColor:16777215,elementColors:{},defaultResidueColor:16777215,residueColors:{},chainColors:[16777215],defaultSecondaryColor:16777215,secondaryColors:{},defaultGradientColor:0,defaultNamedColor:16777215,namedColorsArray:[["indianred",13458524],["lightcoral",15761536],["salmon",16416882],["darksalmon",15308410],["lightsalmon",16752762],["crimson",14423100],["red",16711680],["firebrick",11674146],["darkred",9109504],["pink",16761035],["lightpink",16758465],["hotpink",16738740],["deeppink",16716947],["mediumvioletred",13047173],["palevioletred",14381203],["coral",16744272],["tomato",16737095],["orangered",16729344],["darkorange",16747520],["orange",16753920],["gold",16766720],["yellow",16776960],["lightyellow",16777184],["lemonchiffon",16775885],["lightgoldenrodyellow",16448210],["papayawhip",16773077],["moccasin",16770229],["peachpuff",16767673],["palegoldenrod",15657130],["khaki",15787660],["darkkhaki",12433259],["lavender",15132410],["thistle",14204888],["plum",14524637],["violet",15631086],["orchid",14315734],["fuchsia",16711935],["magenta",16711935],["mediumorchid",12211667],["mediumpurple",9662683],["rebeccapurple",6697881],["blueviolet",9055202],["darkviolet",9699539],["darkorchid",10040012],["darkmagenta",9109643],["purple",8388736],["indigo",4915330],["slateblue",6970061],["mediumslateblue",8087790],["darkslateblue",4734347],["greenyellow",11403055],["chartreuse",8388352],["lawngreen",8190976],["lime",65280],["limegreen",3329330],["palegreen",10025880],["lightgreen",9498256],["mediumspringgreen",64154],["springgreen",65407],["mediumseagreen",3978097],["seagreen",3050327],["forestgreen",2263842],["green",32768],["darkgreen",25600],["yellowgreen",10145074],["olivedrab",7048739],["olive",8421376],["darkolivegreen",5597999],["mediumaquamarine",6737322],["darkseagreen",9419919],["lightseagreen",2142890],["darkcyan",35723],["teal",32896],["aqua",65535],["cyan",65535],["lightcyan",14745599],["paleturquoise",11529966],["aquamarine",8388564],["turquoise",4251856],["mediumturquoise",4772300],["darkturquoise",52945],["cadetblue",6266528],["steelblue",4620980],["lightsteelblue",11584734],["powderblue",11591910],["lightblue",11393254],["skyblue",8900331],["lightskyblue",8900346],["deepskyblue",49151],["dodgerblue",2003199],["cornflowerblue",6591981],["royalblue",4286945],["blue",255],["mediumblue",205],["darkblue",139],["navy",128],["midnightblue",1644912],["cornsilk",16775388],["blanchedalmond",16772045],["bisque",16770244],["navajowhite",16768685],["wheat",16113331],["burlywood",14596231],["tan",13808780],["rosybrown",12357519],["sandybrown",16032864],["goldenrod",14329120],["darkgoldenrod",12092939],["peru",13468991],["chocolate",13789470],["saddlebrown",9127187],["sienna",10506797],["brown",10824234],["maroon",8388608],["white",16777215],["snow",16775930],["honeydew",15794160],["mintcream",16121850],["azure",15794175],["aliceblue",15792383],["ghostwhite",16316671],["whitesmoke",16119285],["seashell",16774638],["beige",16119260],["oldlace",16643558],["floralwhite",16775920],["ivory",16777200],["antiquewhite",16444375],["linen",16445670],["lavenderblush",16773365],["mistyrose",16770273],["gainsboro",14474460],["lightgray",13882323],["silver",12632256],["darkgray",11119017],["gray",8421504],["dimgray",6908265],["lightslategray",7833753],["slategray",7372944],["darkslategray",3100495],["black",0]],namedColors:{},gradients:{rainbow:[255,65535,65280,16776960,16711680],temp:[255,32767,16777215,16744192,16711680],hot:[16777215,16744192,16711680],cold:[16777215,32767,255],"blue-red":[255,16777215,16711680],reds:[16777215,16711680],blues:[16777215,255]}});for(var Go=Uo.prototype,jo=Go.namedColorsArray,Ho=Go.namedColors,Wo=0,Yo=jo.length;Wo=0?this.opts.carbon:this.palette.getElementColor(r)}},{key:"getResidueColor",value:function(e,t){return this.palette.defaultResidueColor}}]),i}(ia);Se(oa,"id","EL"),oa.prototype.id="EL",oa.prototype.name="Element",oa.prototype.shortName="Element";var aa=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(){return a(this,i),n.apply(this,arguments)}return l(i,[{key:"getAtomColor",value:function(e,t){return this.getResidueColor(e.residue,t)}},{key:"getResidueColor",value:function(e,t){return this.palette.getResidueColor(e._type._name)}}]),i}(ia);Se(aa,"id","RT"),aa.prototype.id="RT",aa.prototype.name="Residue Type",aa.prototype.shortName="Residue";var sa=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(){return a(this,i),n.apply(this,arguments)}return l(i,[{key:"getAtomColor",value:function(e,t){return this.getResidueColor(e.residue,t)}},{key:"getResidueColor",value:function(e,t){var r=e._chain;if(r.minSequence===Number.POSITIVE_INFINITY&&r.maxSequence===Number.NEGATIVE_INFINITY)return this.palette.defaultNamedColor;var n=r.minSequence,i=r.maxSequence>n?r.maxSequence:n+1;return this.palette.getGradientColor((e._sequence-n)/(i-n),this.opts.gradient)}}]),i}(ia);Se(sa,"id","SQ"),sa.prototype.id="SQ",sa.prototype.name="Sequence",sa.prototype.shortName="Sequence";var la=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(){return a(this,i),n.apply(this,arguments)}return l(i,[{key:"getAtomColor",value:function(e,t){return this.getResidueColor(e.residue,t)}},{key:"getResidueColor",value:function(e,t){return this.palette.getChainColor(e.getChain()._name)}}]),i}(ia);Se(la,"id","CH"),la.prototype.id="CH",la.prototype.name="Chain",la.prototype.shortName="Chain";var ca=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(){return a(this,i),n.apply(this,arguments)}return l(i,[{key:"getAtomColor",value:function(e,t){return this.getResidueColor(e.residue,t)}},{key:"getResidueColor",value:function(e,t){if(e._type.flags&Le.Flags.DNA)return this.palette.getSecondaryColor("dna");if(e._type.flags&Le.Flags.RNA)return this.palette.getSecondaryColor("rna");var r=e.getSecondary();if(r){var n=this.palette.getSecondaryColor(r.type,!0);return void 0===n&&(n=this.palette.getSecondaryColor(r.generic)),n}return this.palette.defaultSecondaryColor}}]),i}(ia);Se(ca,"id","SS"),ca.prototype.id="SS",ca.prototype.name="Secondary Structure",ca.prototype.shortName="Structure";var ua=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(){return a(this,i),n.apply(this,arguments)}return l(i,[{key:"getAtomColor",value:function(e,t){return this.opts.color}},{key:"getResidueColor",value:function(e,t){return this.opts.color}}]),i}(ia);Se(ua,"id","UN"),ua.prototype.id="UN",ua.prototype.name="Uniform",ua.prototype.shortName="Uniform";var ha=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(e){var t;a(this,i),t=n.call(this,e);var r=wt.parse(t.opts.subset);return t._subsetCached=r.error?wt.none():r.selector,t}return l(i,[{key:"getAtomColor",value:function(e,t){return this._subsetCached.includesAtom(e)?this.opts.color:this.opts.baseColor}},{key:"getResidueColor",value:function(e,t){for(var r=this._subsetCached,n=e._atoms,i=0,o=n.length;ir.max?1:0:(e.temperature-r.min)/(r.max-r.min),this.palette.getGradientColor(n,r.gradient)):this.palette.defaultGradientColor}},{key:"getResidueColor",value:function(e,t){var r=this.opts;if(!r)return this.palette.defaultGradientColor;if(e.temperature){var n;return n=r.min===r.max?e.temperature>r.max?1:0:(e.temperature-r.min)/(r.max-r.min),this.palette.getGradientColor(n,r.gradient)}return this.palette.defaultGradientColor}}]),i}(ia);Se(da,"id","TM"),da.prototype.id="TM",da.prototype.name="Temperature",da.prototype.shortName="Temperature";var pa=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(){return a(this,i),n.apply(this,arguments)}return l(i,[{key:"_getColorByOccupancy",value:function(e,t){if(void 0!==e){var r=1-e;return this.palette.getGradientColor(r,t.gradient)}return this.palette.defaultGradientColor}},{key:"getAtomColor",value:function(e,t){var r=this.opts;return this._getColorByOccupancy(e.occupancy,r)}},{key:"getResidueColor",value:function(e,t){var r=this.opts;return this._getColorByOccupancy(e.occupancy,r)}}]),i}(ia);Se(pa,"id","OC"),pa.prototype.id="OC",pa.prototype.name="Occupancy",pa.prototype.shortName="Occupancy";var ma=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(){return a(this,i),n.apply(this,arguments)}return l(i,[{key:"getAtomColor",value:function(e,t){return this.getResidueColor(e.residue,t)}},{key:"getResidueColor",value:function(e,t){var r=this.palette.defaultResidueColor;return void 0!==e._type.hydrophobicity&&(r=this.palette.getGradientColor((e._type.hydrophobicity- -4.5)/9,this.opts.gradient)),r}}]),i}(ia);Se(ma,"id","HY"),ma.prototype.id="HY",ma.prototype.name="Hydrophobicity",ma.prototype.shortName="Hydrophobicity";var va=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(){return a(this,i),n.apply(this,arguments)}return l(i,[{key:"getAtomColor",value:function(e,t){return this.getResidueColor(e.residue,t)}},{key:"getResidueColor",value:function(e,t){var r=e._molecule,n=t.getMoleculeCount();return n>1?this.palette.getGradientColor((r.index-1)/(n-1),this.opts.gradient):this.palette.getGradientColor(0,this.opts.gradient)}}]),i}(ia);Se(va,"id","MO"),va.prototype.id="MO",va.prototype.name="Molecule",va.prototype.shortName="Molecule";var ya=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(){return a(this,i),n.apply(this,arguments)}return l(i,[{key:"getAtomColor",value:function(e,t){var r,n,i=this.opts.color,o=(r=i,(n=this.opts.factor)*(r>>16&255)<<16|n*(r>>8&255)<<8|n*(255&r));return e.flags&Ce.Flags.CARBON?i:o}},{key:"getResidueColor",value:function(e,t){return this.opts.color}}]),i}(ia);Se(ya,"id","CB"),ya.prototype.id="CB",ya.prototype.name="Carbon",ya.prototype.shortName="Carbon";var _a=new Mr([oa,aa,sa,la,ca,ua,ha,fa,da,pa,ma,va,ya]);function ga(e){return new i.Ilk(e,e,e)}var xa=new Mr([{id:"DF",name:"Diffuse",shortName:"Diffuse",uberOptions:{diffuse:ga(1),specular:ga(0),shininess:1,opacity:1},values:{lights:!0,fog:!0,depthWrite:!0,transparent:!1,toonShading:!1}},{id:"SF",name:"Soft Plastic",shortName:"Soft",uberOptions:{diffuse:ga(1),specular:ga(.1),shininess:30,opacity:1},values:{lights:!0,fog:!0,depthWrite:!0,transparent:!1,toonShading:!1}},{id:"PL",name:"Glossy Plastic",shortName:"Glossy",uberOptions:{diffuse:ga(.56),specular:ga(.28),shininess:100,opacity:1},values:{lights:!0,fog:!0,depthWrite:!0,transparent:!1,toonShading:!1}},{id:"ME",name:"Metal",shortName:"Metal",uberOptions:{diffuse:ga(.56),specular:ga(.55),shininess:30,opacity:1},values:{lights:!0,fog:!0,depthWrite:!0,transparent:!1,toonShading:!1}},{id:"TR",name:"Transparent",shortName:"Transparent",uberOptions:{diffuse:ga(1),specular:ga(0),shininess:1,opacity:.5},values:{lights:!0,fog:!0,depthWrite:!0,transparent:!0,toonShading:!1}},{id:"GL",name:"Glass",shortName:"Glass",uberOptions:{diffuse:ga(.5),specular:ga(.65),shininess:100,opacity:.5},values:{lights:!0,fog:!0,depthWrite:!0,transparent:!0,toonShading:!1}},{id:"BA",name:"Backdrop",shortName:"Backdrop",uberOptions:{diffuse:ga(1),specular:ga(0),shininess:1,opacity:1},values:{lights:!1,fog:!1,depthWrite:!1,transparent:!1,toonShading:!1}},{id:"TN",name:"Toon",shortName:"Toon",uberOptions:{diffuse:ga(1),specular:ga(0),shininess:1,opacity:1},values:{lights:!0,fog:!0,depthWrite:!0,transparent:!1,toonShading:!0}},{id:"FL",name:"Flat",shortName:"Flat",uberOptions:{diffuse:ga(1),specular:ga(0),shininess:0,opacity:1},values:{lights:!1,fog:!0,depthWrite:!0,transparent:!1}}]);function ba(e,t,r){var n=e.material.createInstance();n.setValues(t);var i=new e.constructor(e.geometry,n);return i.material.needsUpdate=!0,i.applyMatrix4(e.matrix),i.layers.set(r),i}function wa(e,t,r){for(var n=function(e,t){var r=[];return e.traverse((function(e){for(var n=0;n0){(t=new i.ZAu).matrixAutoUpdate=!1,t.matrix=this.geo.matrix;for(var n=0;n2)return B.error("Can only edit fragments with one or two bound atoms."),!1;this._fragmentBoundAtoms=r;var n=1<0?this._reprList[0]:null,this._selectionBit=e.length,this._reprUsedBits|=1<=0&ðis._reprList.length)return B.error("Rep ".concat(e," does not exist!")),null;if(e===this._reprList.length){var r=this.repAdd(t);return B.warn("Rep ".concat(e," does not exist! New representation was created.")),{desc:r.desc,index:e,status:"created"}}var i=this._reprList[e],o={selector:i.selectorString,mode:i.mode.identify(),colorer:i.colorer.identify(),material:i.materialPreset.id};if(t){var a=i.change(t,this._complex,za(Fo,t.mode),za(_a,t.colorer));if(!(0,n.isEmpty)(a)){for(var s in i.needsRebuild=!0,a)a.hasOwnProperty(s)&&(o[s]=a[s],B.debug("rep[".concat(e,"].").concat(s," changed to ").concat(a[s])));return a.mode&&i.mode.isSurface&&("ultra"===J.now.resolution||"high"===J.now.resolution)&&(B.report('Surface resolution was changed to "medium" to avoid hang-ups.'),J.set("resolution","medium")),{desc:o,index:e,status:"changed"}}}return{desc:o,index:e,status:""}}},{key:"repGet",value:function(e){return(void 0===e||e instanceof Object)&&(e=this.repCurrent()),e<0||e>=this._reprList.length?null:this._reprList[e]}},{key:"_getFreeReprIdx",value:function(){for(var e=this._reprUsedBits,t=0;t<=s.NUM_REPRESENTATION_BITS;++t,e>>=1)if(0==(1&e))return t;return-1}},{key:"repAdd",value:function(e){if(this._reprList.length>=s.NUM_REPRESENTATION_BITS)return null;var t=this._getFreeReprIdx();if(t<0)return null;var r=this.buildSelectorFromMask(1<=t||t<=1)){var r=this._reprList[e];r.unmarkAtoms(this._complex),this._reprUsedBits&=~(1<=this._reprList.length||this._reprList[e].show(!t)}},{key:"select",value:function(e,t){t?this._selectionCount+=this._complex.markAtomsAdditionally(e,1<0&&(a=Da.chain(r),o=o?Da.or(o,a):a),Object.keys(t).length>0)for(var s in t)t.hasOwnProperty(s)&&(a=Da.and(Da.chain(s),Da.residx(i(t[s]))),o=o?Da.or(o,a):a);e.length>0&&(a=Da.serial(i(e)),o=o?Da.or(o,a):a),o||(o=Da.none())}return o}},{key:"buildSelectorFromMask",value:function(e){var t=this._complex,r=[],n={},i=[];return t.forEachChain((function(t){t._mask&e&&r.push(t._name)})),t.forEachResidue((function(t){if(t._mask&e&&!(t._chain._mask&e)){var r=t._chain._name;r in n?n[r].push(t._index):n[r]=[t._index]}})),t.forEachAtom((function(t){t.mask&e&&!(t.residue._mask&e)&&i.push(t.serial)})),this._buildSelectorFromSortedLists(i,n,r)}},{key:"forSelectedResidues",value:function(e){var t=1<1&&void 0!==arguments[1]&&arguments[1],r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0,n=0,o=this._reprList.length;n 1.0)\r\n return NO_COLOR;\r\n\r\n currDelta.x += mix(textCoord.y, 1.0 - textCoord.y, boxAngles.z) * delta.x;\r\n\r\n textCoord.x = (boxCoord.x - currDelta.x) / (1. - delta.x - delta.y);\r\n if (textCoord.x < 0.0 || textCoord.x > 1.0)\r\n return NO_COLOR;\r\n\r\n return sample3DTexture(textCoord);\r\n}\r\n\r\nfloat CalcColor(vec3 iter, vec3 dir) {\r\n float d = 1. / 128.;\r\n vec3 dx = vec3(d, 0.0, 0.0);\r\n vec3 dy = vec3(0.0, d, 0.0);\r\n vec3 dz = vec3(0.0, 0.0, d);\r\n\r\n // #Opt: coordInc.x:(iter + dx).x > 1. ? 0.: sample3DTextureInclined(iter + dx).x,\r\n vec3 coordInc = mix(\r\n vec3(\r\n sample3DTextureInclined(iter + dx).x,\r\n sample3DTextureInclined(iter + dy).x,\r\n sample3DTextureInclined(iter + dz).x\r\n ),\r\n vec3(0. ,0. , 0.),\r\n vec3(floor((iter + dx).x), floor((iter + dy).y), floor((iter + dz).z))\r\n );\r\n\r\n // #Opt: coordDec.x:(iter - dx).x < 0. ? 0.: sample3DTextureInclined(iter - dx).x,\r\n vec3 coordDec = mix(\r\n vec3(0. ,0. , 0.),\r\n vec3(\r\n sample3DTextureInclined(iter - dx).x,\r\n sample3DTextureInclined(iter - dy).x,\r\n sample3DTextureInclined(iter - dz).x\r\n ),\r\n vec3(ceil((iter - dx).x), ceil((iter - dy).y), ceil((iter - dz).z))\r\n );\r\n\r\n vec3 N = normalize(coordInc - coordDec);\r\n float dif = max(0.0, dot(N, dir));\r\n return dif;\r\n}\r\n\r\nvec3 AccuracyIso(vec3 left, vec3 right, float volLeft, float threshold) {\r\n for (int i = 0; i < 5; i++) {\r\n vec3 iterator = 0.5 * (left + right);\r\n float vol = sample3DTextureInclined(iterator).r;\r\n if ((volLeft - threshold) * (vol - threshold) < 0.)\r\n right = iterator;\r\n else\r\n left = iterator;\r\n }\r\n return 0.5 * (left + right);\r\n}\r\n\r\nvec3 CorrectIso(vec3 left, vec3 right, float tr) {\r\n for (int j = 0; j < 5; j++) {\r\n vec3 iterator = 0.5 * (left + right);\r\n float vol = sample3DTextureInclined(iterator).r;\r\n if (vol < tr)\r\n right = iterator;\r\n else\r\n left = iterator;\r\n }\r\n return 0.5 * (left + right);\r\n}\r\n\r\nvec4 GetIso1(vec3 start, vec3 back, float molDist, vec3 dir, float tr, int count) {\r\n float vol, stepSize = (float(count) + 2.) / float(STEPS_COUNT);\r\n vec3 step = stepSize * dir, iterator = start, left, right;\r\n vec4 acc = NO_COLOR;\r\n\r\n for (int i = 0; i < STEPS_COUNT; i++) {\r\n iterator = iterator + step;\r\n vol = sample3DTextureInclined(iterator).r;\r\n if (length(iterator - back) <= stepSize || (vol > tr))\r\n break;\r\n }\r\n\r\n if (vol > tr)\r\n acc = vec4(CorrectIso(iterator, iterator - step, tr).xyz, 1.);\r\n\r\n return acc;\r\n}\r\n\r\nfloat easeOut(float x0, float x1, float x) {\r\n float t = clamp((x - x0) / (x1 - x0), 0.0, 1.0);\r\n return 1.0 - (1.0 - t) * (1.0 - t);\r\n}\r\n\r\nfloat easeIn(float x0, float x1, float x) {\r\n float t = clamp((x - x0) / (x1 - x0), 0.0, 1.0);\r\n return t * t;\r\n}\r\n\r\nvec3 GetColSimple(float vol) {\r\n float t = easeOut(_isoLevel0.x, _isoLevel0.y, vol);\r\n float s = easeIn(_isoLevel0.y, _isoLevel0.z, vol);\r\n return vec3(0.5, 0.6, 0.7) * (1.0 - t) + 2.0 * vec3(s, 0, 0);\r\n}\r\n\r\nvec4 VolRender(vec3 start, vec3 back, float molDist, vec3 dir) {\r\n vec4 acc = NO_COLOR, iso;\r\n vec3 iterator = start, sumColor = vec3(0., 0., 0.);\r\n float stepSize, alpha, sumAlpha = 0.0, vol, curStepSize, molD;\r\n vec3 step, col, colOld, right;\r\n float tr0 = _isoLevel0.x;\r\n float dif, r, kd, finish;\r\n int count = 0, stopMol = 0;\r\n\r\n for (int k = 0; k < 3; k++) {\r\n stepSize = (float(k) + 2.) / float(STEPS_COUNT);\r\n kd = 140. * tr0 * stepSize;\r\n r = 1. - kd;\r\n step = stepSize * dir;\r\n iso = GetIso1(iterator, back, molDist, dir, tr0, k);\r\n if (iso.a < 0.1 || length(iso.xyz - start) > molDist)\r\n break;\r\n iterator = iso.xyz;\r\n dif = 1.;// CalcColor(iterator, dir);\r\n colOld = GetColSimple(tr0);\r\n curStepSize = stepSize;\r\n for (int i = 0; i < STEPS_COUNT; i++) {\r\n iterator = iterator + step;\r\n molD = length(iterator - start);\r\n vol = sample3DTextureInclined(iterator).r;\r\n finish = distance(iterator, back) - stepSize;\r\n if (finish < 0.0 || vol < tr0 || (sumAlpha > 0.97) || molD > molDist)\r\n break;\r\n alpha = (1. - r);\r\n col = GetColSimple(vol);\r\n vol = sample3DTextureInclined(iterator - 0.5 * step).r;\r\n vec3 colMid = GetColSimple(vol);\r\n sumColor += (1. - sumAlpha) * (colOld + 4.* colMid + col) * alpha / 6.;\r\n sumAlpha += (1. - sumAlpha) * alpha;// *(1. - 1.0*dif*dif);\r\n colOld = col;\r\n } // for i\r\n\r\n if (finish < 0.0 || sumAlpha > 0.97)\r\n break;\r\n\r\n if (molD > molDist) {\r\n curStepSize = stepSize - (molD - molDist);\r\n right = iterator - (molD - molDist) * dir;\r\n vol = sample3DTextureInclined(right).r;\r\n } else {\r\n vec3 left = iterator - step;\r\n right = CorrectIso(left, iterator, tr0);\r\n curStepSize = distance(left, right);\r\n vol = tr0;\r\n }\r\n\r\n alpha = (1. - r) * curStepSize / stepSize;\r\n dif = 1.;// CalcColor(right, dir);\r\n col = GetColSimple(vol);\r\n vol = sample3DTextureInclined(iterator - 0.5 * curStepSize / stepSize * step).r;\r\n vec3 colMid = GetColSimple(vol);\r\n sumColor += (1. - sumAlpha) * (colOld + 4. * colMid + col) * alpha / 6.;\r\n sumAlpha += (1. - sumAlpha) * alpha;// *(1. - 1.0*dif*dif);\r\n\r\n if (molD > molDist)\r\n break;\r\n } // for k\r\n acc.rgb = 1. * sumColor / sumAlpha;\r\n acc.a = sumAlpha;\r\n return acc;\r\n}\r\n\r\nvec4 VolRender1(vec3 start, vec3 back, float molDist, vec3 dir) {\r\n float stepSize = 1.0 / float(STEPS_COUNT);\r\n float len = length(back - start);\r\n vec3 step = stepSize * dir;\r\n vec3 iterator = start;\r\n float acc = 0.0;\r\n\r\n for (int i = 0; i < STEPS_COUNT; i++) {\r\n if (float(i) * stepSize > len)\r\n break;\r\n iterator = iterator + step;\r\n if (sample3DTextureInclined(iterator).r > _isoLevel0.x)\r\n acc += 10. * sample3DTextureInclined(iterator).r / float(STEPS_COUNT);\r\n }\r\n\r\n return vec4(1.,1.,1., acc);\r\n}\r\n\r\nvec4 IsoRender(vec3 start, vec3 back, float molDist, vec3 dir) {\r\n vec4 tst = GetIso1(start, back, 2., dir, _isoLevel0.x, 0);\r\n vec4 col = NO_COLOR;\r\n\r\n if (length(tst.xyz - start) < molDist && tst.a > 0.1) {\r\n float dif = CalcColor(tst.xyz, dir);\r\n dif = 0.9 * dif * dif;\r\n col = vec4(dif, dif, dif, 1);\r\n }\r\n return col;\r\n}\r\n\r\nvec4 VolRender2(vec3 start, vec3 back, float molDist, vec3 dir) {\r\n return sample3DTexture(start);\r\n}\r\n\r\nvoid main() {\r\n vec3 tc = screenSpacePos.xyz / screenSpacePos.w * 0.5 + 0.5;\r\n\r\n if (_flipV > 0.0) {\r\n tc.y = 1.0 - tc.y;\r\n }\r\n\r\n vec3 start;\r\n vec3 back;\r\n vec3 molBack;\r\n if (projectionMatrix[0][2] < 0.0) {\r\n start = texture2D(_FFLeft, tc.xy).xyz;\r\n back = texture2D(_BFLeft, tc.xy).xyz;\r\n molBack = texture2D(_WFFLeft, tc.xy).xyz;\r\n } else {\r\n start = texture2D(_FFRight, tc.xy).xyz;\r\n back = texture2D(_BFRight, tc.xy).xyz;\r\n molBack = texture2D(_WFFRight, tc.xy).xyz;\r\n }\r\n\r\n vec3 dir = normalize(back - start);\r\n\r\n float molDist = 2.0;\r\n if (length(molBack) > 0.001) {\r\n molDist = distance(start, molBack);\r\n }\r\n\r\n #ifdef ISO_MODE\r\n gl_FragColor = IsoRender(start, back, molDist, dir);\r\n #else\r\n gl_FragColor = VolRender(start, back, molDist, dir);\r\n #endif\r\n}\r\n");return i.transparent=!0,i.depthTest=!0,(n=t.call(this,i)).updateDefines(),n}return l(r,[{key:"updateDefines",value:function(){this.defines={ISO_MODE:J.now.modes.VD.isoMode,STEPS_COUNT:100*J.now.modes.VD.polyComplexity[J.now.resolution]},this.needsUpdate=!0}}]),r}(i.jyz)};var Xa=function(e){h(o,e);var t,r,n=(t=o,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function o(){var e;a(this,o);var t=new i.u9r;Se(c(e=n.call(this,t)),"volumeInfo",{}),e.clipPlane=new i.JOQ;var r=new i.Pa4(.5,.5,.5);return e.size=r,e.cullFlag=[!0,!0,!0,!0,!0,!0,!0,!0,!1,!1,!1,!1,!1,!1],e.faces=[{indices:[],norm:new i.Pa4(0,0,-1)},{indices:[],norm:new i.Pa4(0,0,1)},{indices:[],norm:new i.Pa4(0,-1,0)},{indices:[],norm:new i.Pa4(0,1,0)},{indices:[],norm:new i.Pa4(-1,0,0)},{indices:[],norm:new i.Pa4(1,0,0)},{indices:[],norm:new i.Pa4(0,0,0)}],e.vertices=[new i.Pa4(-r.x,-r.y,-r.z),new i.Pa4(-r.x,r.y,-r.z),new i.Pa4(r.x,-r.y,-r.z),new i.Pa4(r.x,r.y,-r.z),new i.Pa4(-r.x,-r.y,r.z),new i.Pa4(-r.x,r.y,r.z),new i.Pa4(r.x,-r.y,r.z),new i.Pa4(r.x,r.y,r.z),new i.Pa4(0,0,0),new i.Pa4(0,0,0),new i.Pa4(0,0,0),new i.Pa4(0,0,0),new i.Pa4(0,0,0),new i.Pa4(0,0,0)],t.setAttribute("position",new i.TlE(new Float32Array(3*e.vertices.length),3)),e.name="VolumeMesh",e}return l(o,[{key:"_updateVertices",value:function(){var e,t=o._corners,r=o._edges,n=o._edgeIntersections,a=this.clipPlane.normal,s=this.clipPlane.constant,l=this.vertices,c=this.size,u=[0,0,0,0,0,0,0,0],h=[1,1,1,1,1,1,1,1,1,1,1,1],f=new i.Pa4,d=null;function p(){if(0===a.x)return 0;var e=-(a.dot(f)+s)/a.x;return-c.x<=e&&e<=c.x?(d.set(e,f.y,f.z),e===c.x?2:e===-c.x?-2:1):0}function m(){if(0===a.y)return 0;var e=-(a.dot(f)+s)/a.y;return-c.y<=e&&e<=c.y?(d.set(f.x,e,f.z),e===c.y?2:e===-c.y?-2:1):0}function v(){if(0===a.z)return 0;var e=-(a.dot(f)+s)/a.z;return-c.z<=e&&e<=c.z?(d.set(f.x,f.y,e),e===c.z?2:e===-c.z?-2:1):0}for(var y=0;y<12;++y){var _=r[y];d=n[y],f.set(_[2],_[3],_[4]),f.multiply(c);var g=0;0===_[2]&&(g=p()),0===_[3]&&(g=m()),0===_[4]&&(g=v()),-2===g?u[_[0]]=1:2===g?u[_[1]]=1:0===g&&(h[y]=0)}var x={indices:[],norm:a.clone().negate()},b=8;for(e=0;e<8;++e)1===u[e]&&(l[b].set(t[e][0],t[e][1],t[e][2]).multiply(c),x.indices.push(b++),h[t[e][3]]=0,h[t[e][4]]=0,h[t[e][5]]=0);for(e=0;e<12;++e)1===h[e]&&(l[b].copy(n[e]),x.indices.push(b++));this.faces[6]=x;var w=new i.Pa4,S=new i.Pa4;for(this.clipPlane.coplanarPoint(S),e=0;e=0):e<8+x.indices.length&&(this.cullFlag[e]=!0);var C=this.geometry.getAttribute("position"),R=0;for(e=0;e=3&&(h+=3*(r.indices.length-2));var f=0,d=new Uint16Array(h);for(t=0;t0&&void 0!==arguments[0]?arguments[0]:[];return a(this,i),n.call(this,e,["types"])}return l(i,[{key:"find",value:function(e){var t=[];if(e.type)t=this._dict.types[e.type.toLowerCase()]||[];else if(e.source)return this._list.filter((function(t){return t.canProbablyLoad&&t.canProbablyLoad(e.source)}));return Pr(t)}}]),i}(Mr);var Qa=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(e,t){var r;return a(this,i),(r=n.call(this))._source=e,r._options=t||{},r._abort=!1,r._agent=null,r}return l(i,[{key:"load",value:function(){return Promise.reject(new Error("Loading from this source is not implemented"))}},{key:"abort",value:function(){this._abort=!0,this._agent&&this._agent.abort()}}],[{key:"extractName",value:function(e){}}]),i}(N);Nr(Qa.prototype);var Ja=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(e,t){var r;return a(this,i),t=(r=n.call(this,e,t))._options,r._binary=!0===t.binary,r}return l(i,[{key:"load",value:function(){var e=this;return new Promise((function(t,r){if(e._abort)throw new Error("Loading aborted");var n=e._source,i=e._agent=new FileReader;i.addEventListener("load",(function(){t(i.result)})),i.addEventListener("error",(function(){r(i.error)})),i.addEventListener("abort",(function(){r(new Error("Loading aborted"))})),i.addEventListener("progress",(function(t){e.dispatchEvent(t)})),e._binary?i.readAsArrayBuffer(n):i.readAsText(n)}))}}],[{key:"canProbablyLoad",value:function(e){return File&&e instanceof File||Blob&&e instanceof Blob}},{key:"extractName",value:function(e){return e&&e.name}}]),i}(Qa);Ja.types=["file","blob"];var es=/^(https?|ftp):\/\//i,ts=function(e){h(o,e);var t,r,i=(t=o,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function o(e,t){var r;return a(this,o),t=(r=i.call(this,e,t))._options,r._binary=!0===t.binary,r}return l(o,[{key:"load",value:function(){var e=this;return new Promise((function(t,r){if(e._abort)throw new Error("Loading aborted");var n=e._source,i=e._agent=new XMLHttpRequest;i.addEventListener("load",(function(){200===i.status?t(i.response):r(new Error("HTTP ".concat(i.status," while fetching ").concat(n)))})),i.addEventListener("error",(function(){r(new Error("HTTP request failed"))})),i.addEventListener("abort",(function(){r(new Error("Loading aborted"))})),i.addEventListener("progress",(function(t){e.dispatchEvent(t)})),i.open("GET",n),e._binary?i.responseType="arraybuffer":i.responseType="text",i.send()}))}}],[{key:"canProbablyLoad",value:function(e){return(0,n.isString)(e)&&es.test(e)}},{key:"extractName",value:function(e){if(e){var t=(e.indexOf("?")+1||e.lastIndexOf("#")+1||e.length+1)-1;return e.slice(e.lastIndexOf("/",t)+1,t)}}}]),o}(Qa);ts.types=["url"];var rs=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(){return a(this,i),n.apply(this,arguments)}return l(i,[{key:"load",value:function(){var e=this;return new Promise((function(t){if(e._abort)throw new Error("Loading aborted");t(e._source)}))}}],[{key:"canProbablyLoad",value:function(e){return!1}}]),i}(Qa);rs.types=["immediate"];var ns=new Ka([Ja,ts,rs]);var is=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return a(this,i),n.call(this,e,["formats","extensions"])}return l(i,[{key:"find",value:function(e){var t=[];return e.format?t=this._dict.formats[e.format.toLowerCase()]||[]:e.ext&&(t=this._dict.extensions[e.ext.toLowerCase()]||[]),0===t.length&&!e.format&&e.data?this._list.filter((function(t){return t.canProbablyParse&&t.canProbablyParse(e.data)})):Pr(t)}}]),i}(Mr),os=function(){function e(t,r){a(this,e),this._data=t,this._options=r||{},this._abort=!1}return l(e,[{key:"parseSync",value:function(){throw new Error("Parsing this type of data is not implemented")}},{key:"parse",value:function(){var e=this;return new Promise((function(t,r){setTimeout((function(){try{return e._abort?r(new Error("Parsing aborted")):t(e.parseSync())}catch(e){return r(e)}}))}))}},{key:"getModel",value:function(){return this.model._parseHeader(this._data),this.model}},{key:"abort",value:function(){this._abort=!0}}]),e}();Nr(os.prototype);var as=function(){function e(){a(this,e),this.matrices=[],this._matrix=null,this._matrixIndex=-1}return l(e,[{key:"parse",value:function(e){var t=this._matrix;if(" SMTRY"===e.readString(12,18)){var r=e.readCharCode(19)-49,n=e.readString(20,80).trim().split(/\s+/),o=parseInt(n[0],10);null!==this._matrix&&o===this._matrixIndex||(this._matrixIndex=o,this._matrix=t=new i.yGw,this.matrices[this.matrices.length]=t);var a=t.elements;a[r]=parseFloat(n[1]),a[r+4]=parseFloat(n[2]),a[r+8]=parseFloat(n[3]),a[r+12]=parseFloat(n[4])}}}]),e}();as.prototype.id=290;var ss=dr.Assembly,ls=function(){function e(t){a(this,e),this._complex=t,this.assemblies=[],this._assembly=null,this._matrix=null,this._matrixIndex=-1}return l(e,[{key:"parse",value:function(e){var t=this._assembly,r=this._matrix;if(t&&" BIOMT"===e.readString(12,18)){var n=e.readCharCode(19)-49,o=e.readString(20,80).trim().split(/\s+/),a=parseInt(o[0],10);null!==this._matrix&&a===this._matrixIndex||(this._matrixIndex=a,this._matrix=r=new i.yGw,t.addMatrix(r));var s=r.elements;s[n]=parseFloat(o[1]),s[n+4]=parseFloat(o[2]),s[n+8]=parseFloat(o[3]),s[n+12]=parseFloat(o[4])}else if(t&&"CHAINS:"===e.readString(35,41))for(var l=e.readString(42,80).split(","),c=0,u=l.length;c0&&t.addChain(h)}else"BIOMOLECULE:"===e.readString(12,23)&&(this._matrix=null,this._matrixIndex=-1,this._assembly=t=new ss(this._complex),this.assemblies.push(t))}}]),e}();ls.prototype.id=350;var cs=function(){function e(t){a(this,e),this._data=t,this._start=0,this._nextCR=-1,this._nextLF=-1,this._next=-1,this._end=t.length,this.next()}return l(e,[{key:"readLine",value:function(){return this._data.slice(this._start,this._next)}},{key:"readChar",value:function(e){return(e=this._start+e-1)=this._end}},{key:"next",value:function(){var e=this._next+1;this._start=ethis._nextCR&&(this._nextCR=(this._data.indexOf("\r",this._start)+1||this._end+1)-1),this._start>this._nextLF&&(this._nextLF=(this._data.indexOf("\n",this._start)+1||this._end+1)-1),this._next=this._nextCR+1t&&a.addBond(t,r,0,ms.BondType.UNKNOWN,!0),n&&n>t&&a.addBond(t,n,0,ms.BondType.UNKNOWN,!0),i&&i>t&&a.addBond(t,i,0,ms.BondType.UNKNOWN,!0),o&&o>t&&a.addBond(t,o,0,ms.BondType.UNKNOWN,!0)}},{key:"_parseCOMPND",value:function(e){var t=e.readString(11,80),r=t.indexOf(":");if(this._compndCurrToken=r>0?t.substring(0,r).trim():this._compndCurrToken,"MOL_ID"===this._compndCurrToken)this._molecule={_index:"",_chains:[]},this._molecule._index=parseInt(t.substring(r+1,t.indexOf(";")),10),this._molecules.push(this._molecule);else if("MOLECULE"===this._compndCurrToken&&null!=this._molecule)this._molecule._name=t.substring(r+1,t.indexOf(";")).trim();else if("CHAIN"===this._compndCurrToken&&null!=this._molecule){var n=t.substring(r+1,80).trim(),i=n[n.length-1];";"!==i&&","!==i||(n=n.slice(0,-1));var o=(n=n.replace(/\s+/g,"")).split(",");this._molecule._chains=this._molecule._chains.concat(o)}}},{key:"_parseREMARK",value:function(e){var t=e.readInt(8,10),r=this._remarks[t];if((0,n.isUndefined)(r)){var i=_s[t];"function"==typeof i&&(this._remarks[t]=r=new i(this._complex))}(0,n.isUndefined)(r)||r.parse(e)}},{key:"_parseHELIX",value:function(e){var t=this;this._parseSTRUCTURE(e,[20,22,32,34],(function(e){t._complex.addHelix(e),t._complex.structures.push(e)}))}},{key:"_parseSHEET",value:function(e){var t=this;this._parseSTRUCTURE(e,[22,23,33,34],(function(e){t._complex.addSheet(e)}))}},{key:"_parseSTRUCTURE",value:function(e,t,r){var n=e.readInt(8,10),i=e.readString(12,14).trim(),o=e.readString(41,70).trim(),a=e.readInt(72,76),s=e.readInt(39,40),l=e.readInt(15,16),c=e.readInt(42,45),u=e.readInt(57,60),h=e.readString(t[0],t[2]+1).charCodeAt(0),f=e.readString(t[2],t[2]+1).charCodeAt(0),d=e.readInt(t[1],t[1]+3),p=e.readString(t[1]+4,t[1]+4),m=0;p.length>0&&(m=p.charCodeAt(0));var v,y=e.readInt(t[3],t[3]+3),_=0;(p=e.readString(t[3]+4,t[3]+4)).length>0&&(_=p.charCodeAt(0));var g=this._sheet;if(83===e.readCharCode(1)){null!==g&&g.getName()!==i&&(g=null,this._sheet=null),null===g?(this._sheet=v=new ds(i,l),r(v)):v=g;var x=new ps(v,this._complex.getUnifiedSerial(h,d,m),this._complex.getUnifiedSerial(f,y,_),s,c,u);v.addStrand(x),this._complex.structures.push(x)}else r(v=new fs(s,this._complex.getUnifiedSerial(h,d,m),this._complex.getUnifiedSerial(f,y,_),n,i,o,a))}},{key:"_parseHEADER",value:function(e){var t=this._complex.metadata;t.classification=e.readString(11,50).trim(),t.date=e.readString(51,59).trim();var r=e.readString(63,66).trim();t.id=r,r&&(this._complex.name=r),t.format="pdb"}},{key:"_parseTITLE",value:function(e){var t=this._complex.metadata;t.title=t.title||[];var r=e.readInt(9,10)||1;t.title[r-1]=e.readString(11,80).trim()}},{key:"parseSync",value:function(){for(var e=new cs(this._data),t=this._complex=new us;!e.end();){var r=e.readString(1,6),n=s.tagParsers[r];"function"==typeof n&&n.call(this,e),e.next()}if(this._finalize(),this._serialAtomMap=null,this._sheet=null,this._residue=null,this._chain=null,this._complex=null,0===t.getAtomCount())throw new Error("The data does not contain valid atoms");return t}}],[{key:"canProbablyParse",value:function(e){return(0,n.isString)(e)&&ys.test(e)}}]),s}(os);Se(gs,"tagParsers",{HEADER:gs.prototype._parseHEADER,"TITLE ":gs.prototype._parseTITLE,"ATOM ":gs.prototype._parseATOM,HETATM:gs.prototype._parseATOM,ENDMDL:gs.prototype._parseENDMDL,CONECT:gs.prototype._parseCONECT,COMPND:gs.prototype._parseCOMPND,REMARK:gs.prototype._parseREMARK,"HELIX ":gs.prototype._parseHELIX,"SHEET ":gs.prototype._parseSHEET,"ATOM 1":gs.prototype._parseATOM,"ATOM 2":gs.prototype._parseATOM,"ATOM 3":gs.prototype._parseATOM,"ATOM 4":gs.prototype._parseATOM,"ATOM 5":gs.prototype._parseATOM,"ATOM 6":gs.prototype._parseATOM,"ATOM 7":gs.prototype._parseATOM,"ATOM 8":gs.prototype._parseATOM,"ATOM 9":gs.prototype._parseATOM}),gs.formats=["pdb"],gs.extensions=[".pdb",".ent"];var xs=dr.Complex,bs=dr.Element,ws=dr.SGroup,Ss=dr.Bond,Cs={A:0,S:1,D:2,T:3},Rs=/\s*<\?xml\b[^?>]*\?>\s*<(?:cml|molecule)\b/i,As=function(e){h(c,e);var t,r,s=(t=c,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function c(e,t){var r;return a(this,c),(r=s.call(this,e,t))._complex=null,r._residue=null,r._serialAtomMap=null,r._modelId=1,r._lastMolId=-1,r._readOnlyOneMolecule=!1,r._options.fileType="cml",r}return l(c,[{key:"_rebuidBondIndexes",value:function(e,t){for(var r=e.length,n=0;n1&&a.splice(1,a.length-1),a.forEach((function(e){var t=function(e){var t,n=[];if(e.molecule&&e.molecule.atomArray&&e.molecule.atomArray.atom)Array.isArray(e.molecule.atomArray.atom)?n=e.molecule.atomArray.atom:n.push(e.molecule.atomArray.atom);else if(!e.molecule)return{atomLabels:null,labelsCount:1};e.molecule.molecule&&i._extractSGroups(e.molecule.molecule,n);for(var o=n.length,a=0;a1)l[c].order=h;else{var f=Cs[u];void 0!==f&&(l[c].order=f,"A"===u&&(l[c].type=Ss.BondType.AROMATIC))}}o=n.length;for(var d=0;d0&&o.push(t)})),o}},{key:"_packLabel",value:function(e,t){return(t<<16)+e}},{key:"_unpackLabel",value:function(e){return{molId:e>>>16,compId:65535&e}}},{key:"_breadWidthSearch",value:function(e,t){var r,n=new Array(e.length);for(r=0;r0;){o++;var s=-1;for(r=0;r0;){var l=i.shift();if(l)for(var c=0;c=0){var i=[Math.min(e,t),Math.max(e,t)];this._complex.addBond(i[0],i[1],r,n,!0)}}},{key:"_fixBondsArray",value:function(){for(var e=this._serialAtomMap={},t=this._complex,r=t._atoms,n=0,i=r.length;n1){var n=new xs;return n.joinComplexes(e),n.originalCML=e[0].originalCML,n}return 1===e.length?e[0]:new xs}}],[{key:"canProbablyParse",value:function(e){return(0,n.isString)(e)&&Rs.test(e)}}]),c}(os);As.formats=["cml"],As.extensions=[".cml"];var Es={};!function(e,t){!function(e){function t(e,t,r){for(var n=(e.byteLength,0),i=r.length;i>n;n++){var o=r.charCodeAt(n);if(128>o)e.setUint8(t++,o>>>0&127|0);else if(2048>o)e.setUint8(t++,o>>>6&31|192),e.setUint8(t++,o>>>0&63|128);else if(65536>o)e.setUint8(t++,o>>>12&15|224),e.setUint8(t++,o>>>6&63|128),e.setUint8(t++,o>>>0&63|128);else{if(!(1114112>o))throw new Error("bad codepoint "+o);e.setUint8(t++,o>>>18&7|240),e.setUint8(t++,o>>>12&63|128),e.setUint8(t++,o>>>6&63|128),e.setUint8(t++,o>>>0&63|128)}}}function r(e){for(var t=0,r=0,n=e.length;n>r;r++){var i=e.charCodeAt(r);if(128>i)t+=1;else if(2048>i)t+=2;else if(65536>i)t+=3;else{if(!(1114112>i))throw new Error("bad codepoint "+i);t+=4}}return t}function n(e,i,a){var s=o(e);if("string"===s){if(32>(l=r(e)))return i.setUint8(a,160|l),t(i,a+1,e),1+l;if(256>l)return i.setUint8(a,217),i.setUint8(a+1,l),t(i,a+2,e),2+l;if(65536>l)return i.setUint8(a,218),i.setUint16(a+1,l),t(i,a+3,e),3+l;if(4294967296>l)return i.setUint8(a,219),i.setUint32(a+1,l),t(i,a+5,e),5+l}if(e instanceof Uint8Array){var l=e.byteLength,c=new Uint8Array(i.buffer);if(256>l)return i.setUint8(a,196),i.setUint8(a+1,l),c.set(e,a+2),2+l;if(65536>l)return i.setUint8(a,197),i.setUint16(a+1,l),c.set(e,a+3),3+l;if(4294967296>l)return i.setUint8(a,198),i.setUint32(a+1,l),c.set(e,a+5),5+l}if("number"===s){if(!isFinite(e))throw new Error("Number not finite: "+e);if(Math.floor(e)!==e)return i.setUint8(a,203),i.setFloat64(a+1,e),9;if(e>=0){if(128>e)return i.setUint8(a,e),1;if(256>e)return i.setUint8(a,204),i.setUint8(a+1,e),2;if(65536>e)return i.setUint8(a,205),i.setUint16(a+1,e),3;if(4294967296>e)return i.setUint8(a,206),i.setUint32(a+1,e),5;throw new Error("Number too big 0x"+e.toString(16))}if(e>=-32)return i.setInt8(a,e),1;if(e>=-128)return i.setUint8(a,208),i.setInt8(a+1,e),2;if(e>=-32768)return i.setUint8(a,209),i.setInt16(a+1,e),3;if(e>=-2147483648)return i.setUint8(a,210),i.setInt32(a+1,e),5;throw new Error("Number too small -0x"+(-e).toString(16).substr(1))}if(null===e)return i.setUint8(a,192),1;if("boolean"===s)return i.setUint8(a,e?195:194),1;if("object"===s){var u=0,h=Array.isArray(e);if(h)l=e.length;else{var f=Object.keys(e);l=f.length}if(16>l?(i.setUint8(a,l|(h?144:128)),u=1):65536>l?(i.setUint8(a,h?220:222),i.setUint16(a+1,l),u=3):4294967296>l&&(i.setUint8(a,h?221:223),i.setUint32(a+1,l),u=5),h)for(var d=0;l>d;d++)u+=n(e[d],i,a+u);else for(d=0;l>d;d++){var p=f[d];u+=n(p,i,a+u),u+=n(e[p],i,a+u)}return u}throw new Error("Unknown type "+s)}function i(e){var t=o(e);if("string"===t){if(32>(n=r(e)))return 1+n;if(256>n)return 2+n;if(65536>n)return 3+n;if(4294967296>n)return 5+n}if(e instanceof Uint8Array){if(256>(n=e.byteLength))return 2+n;if(65536>n)return 3+n;if(4294967296>n)return 5+n}if("number"===t){if(Math.floor(e)!==e)return 9;if(e>=0){if(128>e)return 1;if(256>e)return 2;if(65536>e)return 3;if(4294967296>e)return 5;throw new Error("Number too big 0x"+e.toString(16))}if(e>=-32)return 1;if(e>=-128)return 2;if(e>=-32768)return 3;if(e>=-2147483648)return 5;throw new Error("Number too small -0x"+e.toString(16).substr(1))}if("boolean"===t||null===e)return 1;if("object"===t){var n,a=0;if(Array.isArray(e)){n=e.length;for(var s=0;n>s;s++)a+=i(e[s])}else{var l=Object.keys(e);for(n=l.length,s=0;n>s;s++){var c=l[s];a+=i(c)+i(e[c])}}if(16>n)return 1+a;if(65536>n)return 3+a;if(4294967296>n)return 5+a;throw new Error("Array or object too long 0x"+n.toString(16))}throw new Error("Unknown type "+t)}function a(e){var t=new ArrayBuffer(i(e));return n(e,new DataView(t),0),new Uint8Array(t)}function s(e,t,r){return t?new e(t.buffer,t.byteOffset,t.byteLength/(r||1)):void 0}function l(e){return s(DataView,e)}function c(e){return s(Uint8Array,e)}function u(e){return s(Int8Array,e)}function h(e){return s(Int32Array,e,4)}function f(e,t){var r=e.length/2;t||(t=new Int16Array(r));for(var n=0,i=0;r>n;++n,i+=2)t[n]=e[i]<<8^e[i+1]<<0;return t}function d(e,t){var r=e.length/4;t||(t=new Int32Array(r));for(var n=0,i=0;r>n;++n,i+=4)t[n]=e[i]<<24^e[i+1]<<16^e[i+2]<<8^e[i+3]<<0;return t}function p(e,t){var r=e.length;t||(t=new Uint8Array(4*r));for(var n=l(t),i=0;r>i;++i)n.setInt32(4*i,e[i]);return c(t)}function m(e,t,r){var n=e.length,i=1/t;r||(r=new Float32Array(n));for(var o=0;n>o;++o)r[o]=e[o]*i;return r}function v(e,t,r){var n=e.length;r||(r=new Int32Array(n));for(var i=0;n>i;++i)r[i]=Math.round(e[i]*t);return r}function y(e,t){var r,n;if(!t){var i=0;for(r=0,n=e.length;n>r;r+=2)i+=e[r+1];t=new e.constructor(i)}var o=0;for(r=0,n=e.length;n>r;r+=2)for(var a=e[r],s=e[r+1],l=0;s>l;++l)t[o]=a,++o;return t}function _(e){if(0===e.length)return new Int32Array;var t,r,n=2;for(t=1,r=e.length;r>t;++t)e[t-1]!==e[t]&&(n+=2);var i=new Int32Array(n),o=0,a=1;for(t=1,r=e.length;r>t;++t)e[t-1]!==e[t]?(i[o]=e[t-1],i[o+1]=a,a=1,o+=2):++a;return i[o]=e[e.length-1],i[o+1]=a,i}function g(e,t){var r=e.length;t||(t=new e.constructor(r)),r&&(t[0]=e[0]);for(var n=1;r>n;++n)t[n]=e[n]+t[n-1];return t}function x(e,t){var r=e.length;t||(t=new e.constructor(r)),t[0]=e[0];for(var n=1;r>n;++n)t[n]=e[n]-e[n-1];return t}function b(e,t){var r,n,i=e instanceof Int8Array?127:32767,o=-i-1,a=e.length;if(!t){var s=0;for(r=0;a>r;++r)e[r]o&&++s;t=new Int32Array(s)}for(r=0,n=0;a>r;){for(var l=0;e[r]===i||e[r]===o;)l+=e[r],++r;l+=e[r],++r,t[n]=l,++n}return t}function w(e,t,r){return m(b(e,h(r)),t,r)}function S(e,t,r){var n=b(e,h(r));return function(e,t,r){return m(g(e,h(r)),t,r)}(n,t,function(e){return s(Float32Array,e,4)}(n))}function C(e,t,r){return function(e,t){var r,n=t?127:32767,i=-n-1,o=e.length,a=0;for(r=0;o>r;++r)0===(c=e[r])?++a:a+=c===n||c===i?2:c>0?Math.ceil(c/n):Math.ceil(c/i);var s=t?new Int8Array(a):new Int16Array(a),l=0;for(r=0;o>r;++r){var c;if((c=e[r])>=0)for(;c>=n;)s[l]=n,++l,c-=n;else for(;i>=c;)s[l]=i,++l,c-=i;s[l]=c,++l}return s}(function(e,t,r){return x(v(e,t),r)}(e,t),r)}function R(e,t,r,n){var i=new ArrayBuffer(12+n.byteLength),o=new Uint8Array(i),a=new DataView(i);return a.setInt32(0,e),a.setInt32(4,t),r&&o.set(r,8),o.set(n,12),o}function A(e){return R(2,e.length,void 0,c(e))}function E(e){return R(4,e.length,void 0,p(e))}function k(e,t){return R(5,e.length/t,p([t]),c(e))}function P(e){return R(6,e.length,void 0,p(_(e)))}function T(e){return R(8,e.length,void 0,p(function(e){return _(x(e))}(e)))}function M(e,t){return R(9,e.length,p([t]),p(function(e,t){return _(v(e,t))}(e,t)))}function N(e,t){return R(10,e.length,p([t]),function(e,t){var r=e.length;t||(t=new Uint8Array(2*r));for(var n=l(t),i=0;r>i;++i)n.setInt16(2*i,e[i]);return c(t)}(C(e,t)))}function I(e){var t={};return V.forEach((function(r){void 0!==e[r]&&(t[r]=e[r])})),e.bondAtomList&&(t.bondAtomList=E(e.bondAtomList)),e.bondOrderList&&(t.bondOrderList=A(e.bondOrderList)),t.xCoordList=N(e.xCoordList,1e3),t.yCoordList=N(e.yCoordList,1e3),t.zCoordList=N(e.zCoordList,1e3),e.bFactorList&&(t.bFactorList=N(e.bFactorList,100)),e.atomIdList&&(t.atomIdList=T(e.atomIdList)),e.altLocList&&(t.altLocList=P(e.altLocList)),e.occupancyList&&(t.occupancyList=M(e.occupancyList,100)),t.groupIdList=T(e.groupIdList),t.groupTypeList=E(e.groupTypeList),e.secStructList&&(t.secStructList=A(e.secStructList)),e.insCodeList&&(t.insCodeList=P(e.insCodeList)),e.sequenceIndexList&&(t.sequenceIndexList=T(e.sequenceIndexList)),t.chainIdList=k(e.chainIdList,4),e.chainNameList&&(t.chainNameList=k(e.chainNameList,4)),t}function O(e){function t(e){for(var t={},r=0;e>r;r++)t[o()]=o();return t}function r(t){var r=e.subarray(a,a+t);return a+=t,r}function n(t){var r=e.subarray(a,a+t);a+=t;var n=65535;if(t>n){for(var i=[],o=0;or;r++)t[r]=o();return t}function o(){var o,l,c=e[a];if(0==(128&c))return a++,c;if(128==(240&c))return a++,t(l=15&c);if(144==(240&c))return a++,i(l=15&c);if(160==(224&c))return a++,n(l=31&c);if(224==(224&c))return o=s.getInt8(a),a++,o;switch(c){case 192:return a++,null;case 194:return a++,!1;case 195:return a++,!0;case 196:return l=s.getUint8(a+1),a+=2,r(l);case 197:return l=s.getUint16(a+1),a+=3,r(l);case 198:return l=s.getUint32(a+1),a+=5,r(l);case 202:return o=s.getFloat32(a+1),a+=5,o;case 203:return o=s.getFloat64(a+1),a+=9,o;case 204:return o=e[a+1],a+=2,o;case 205:return o=s.getUint16(a+1),a+=3,o;case 206:return o=s.getUint32(a+1),a+=5,o;case 208:return o=s.getInt8(a+1),a+=2,o;case 209:return o=s.getInt16(a+1),a+=3,o;case 210:return o=s.getInt32(a+1),a+=5,o;case 217:return l=s.getUint8(a+1),a+=2,n(l);case 218:return l=s.getUint16(a+1),a+=3,n(l);case 219:return l=s.getUint32(a+1),a+=5,n(l);case 220:return l=s.getUint16(a+1),a+=3,i(l);case 221:return l=s.getUint32(a+1),a+=5,i(l);case 222:return l=s.getUint16(a+1),a+=3,t(l);case 223:return l=s.getUint32(a+1),a+=5,t(l)}throw new Error("Unknown type 0x"+c.toString(16))}var a=0,s=new DataView(e.buffer);return o()}function L(e,t,r,n){switch(e){case 1:return function(e,t){var r=e.length;t||(t=new Float32Array(r/4));for(var n=l(t),i=l(e),o=0,a=0,s=r/4;s>o;++o,a+=4)n.setFloat32(a,i.getFloat32(a),!0);return t}(t);case 2:return u(t);case 3:return f(t);case 4:return d(t);case 5:return c(t);case 6:return y(d(t),new Uint8Array(r));case 7:return y(d(t));case 8:return function(e,t){return g(y(e),t)}(d(t));case 9:return function(e,t,r){return m(y(e,h(r)),t,r)}(d(t),d(n)[0]);case 10:return S(f(t),d(n)[0]);case 11:return m(f(t),d(n)[0]);case 12:return w(f(t),d(n)[0]);case 13:return w(u(t),d(n)[0]);case 14:return b(f(t));case 15:return b(u(t))}}function B(e,t){var r=(t=t||{}).ignoreFields,n={};return U.forEach((function(t){var i=!!r&&-1!==r.indexOf(t),o=e[t];i||void 0===o||(o instanceof Uint8Array?n[t]=L.apply(null,function(e){var t=l(e),r=t.getInt32(0),n=t.getInt32(4),i=e.subarray(8,12);return[r,e=e.subarray(12),n,i]}(o)):n[t]=o)})),n}function D(e){return String.fromCharCode.apply(null,e).replace(/\0/g,"")}function z(e,t){return e instanceof ArrayBuffer&&(e=new Uint8Array(e)),B(e instanceof Uint8Array?O(e):e,t)}function F(e,t,r,n){var i=new XMLHttpRequest;i.addEventListener("load",(function(){try{var e=z(i.response);r(e)}catch(e){n(e)}}),!0),i.addEventListener("error",n,!0),i.responseType="arraybuffer",i.open("GET",t+e.toUpperCase()),i.send()}var V=["mmtfVersion","mmtfProducer","unitCell","spaceGroup","structureId","title","depositionDate","releaseDate","experimentalMethods","resolution","rFree","rWork","bioAssemblyList","ncsOperatorList","entityList","groupList","numBonds","numAtoms","numGroups","numChains","numModels","groupsPerChain","chainsPerModel"],U=V.concat(["xCoordList","yCoordList","zCoordList","groupIdList","groupTypeList","chainIdList","bFactorList","atomIdList","altLocList","occupancyList","secStructList","insCodeList","sequenceIndexList","chainNameList","bondAtomList","bondOrderList"]),G="//mmtf.rcsb.org/v1.0/",j=G+"full/",H=G+"reduced/";e.encode=function(e){return a(I(e))},e.decode=z,e.traverse=function(e,t,r){var n,i,o,a,s,l,c=(r=r||{}).firstModelOnly,u=t.onModel,h=t.onChain,f=t.onGroup,d=t.onAtom,p=t.onBond,m=0,v=0,y=0,_=0,g=0,x=-1,b=e.chainNameList,w=e.secStructList,S=e.insCodeList,C=e.sequenceIndexList,R=e.atomIdList,A=e.bFactorList,E=e.altLocList,k=e.occupancyList,P=e.bondAtomList,T=e.bondOrderList;for(n=0,i=e.chainsPerModel.length;i>n&&!(c&&m>0);++n){var M=e.chainsPerModel[m];for(u&&u({chainCount:M,modelIndex:m}),o=0;M>o;++o){var N=e.groupsPerChain[v];if(h){var I=D(e.chainIdList.subarray(4*v,4*v+4)),O=null;b&&(O=D(b.subarray(4*v,4*v+4))),h({groupCount:N,chainIndex:v,modelIndex:m,chainId:I,chainName:O})}for(a=0;N>a;++a){var L=e.groupList[e.groupTypeList[y]],B=L.atomNameList.length;if(f){var z=null;w&&(z=w[y]);var F=null;e.insCodeList&&(F=String.fromCharCode(S[y]));var V=null;C&&(V=C[y]),f({atomCount:B,groupIndex:y,chainIndex:v,modelIndex:m,groupId:e.groupIdList[y],groupType:e.groupTypeList[y],groupName:L.groupName,singleLetterCode:L.singleLetterCode,chemCompType:L.chemCompType,secStruct:z,insCode:F,sequenceIndex:V})}for(s=0;B>s;++s){if(d){var U=null;R&&(U=R[_]);var G=null;A&&(G=A[_]);var j=null;E&&(j=String.fromCharCode(E[_]));var H=null;k&&(H=k[_]),d({atomIndex:_,groupIndex:y,chainIndex:v,modelIndex:m,atomId:U,element:L.elementList[s],atomName:L.atomNameList[s],formalCharge:L.formalChargeList[s],xCoord:e.xCoordList[_],yCoord:e.yCoordList[_],zCoord:e.zCoordList[_],bFactor:G,altLoc:j,occupancy:H})}_+=1}if(p){var W=L.bondAtomList;for(s=0,l=L.bondOrderList.length;l>s;++s)p({atomIndex1:_-B+W[2*s],atomIndex2:_-B+W[2*s+1],bondOrder:L.bondOrderList[s]})}y+=1}v+=1}if(g=x+1,x=_-1,p&&P)for(s=0,l=P.length;l>s;s+=2){var Y=P[s],X=P[s+1];(Y>=g&&x>=Y||X>=g&&x>=X)&&p({atomIndex1:Y,atomIndex2:X,bondOrder:T?T[s/2]:null})}m+=1}},e.fetch=function(e,t,r){F(e,j,t,r)},e.fetchReduced=function(e,t,r){F(e,H,t,r)},e.version="v1.1.0dev",e.fetchUrl=j,e.fetchReducedUrl=H,e.encodeMsgpack=a,e.encodeMmtf=I,e.decodeMsgpack=O,e.decodeMmtf=B}(t)}(0,Es);var ks=Es;var Ps=dr.Complex,Ts=dr.Chain,Ms=dr.Atom,Ns=dr.Element,Is=dr.Helix,Os=dr.Sheet,Ls=dr.Strand,Bs=dr.Bond,Ds=dr.Assembly,zs=dr.Molecule,Fs=function(){function e(t){a(this,e),this._original=Array.from(t),this._original.sort(),this._sum=0;for(var r=0;r=this._complex._atoms.length)){var r=Math.min(e.atomIndex1,e.atomIndex2);this._complex.addBond(this._complex._atoms[r],this._complex._atoms[t],e.bondOrder,Bs.BondType.UNKNOWN,!0)}}},{key:"_updateSecStructure",value:function(e,t,r){if(!(0,n.isUndefined)(r)&&r.secStruct===this._ssType)return t._secondary=this._ssStruct,void(this._ssStruct&&(this._ssStruct.term=t));if(!(0,n.isUndefined)(r)){var i=Us[r.secStruct];this._ssType=r.secStruct,this._ssStart=t;var o=null;switch(this._ssType){case-1:case 7:break;case 0:case 2:case 4:o=new Is([3,-1,1,-1,5][this._ssType],t,t,0,"","",0),e._helices.push(o);break;case 3:var a=new Os("",0);e._sheets.push(a),o=new Ls(a,t,t,0,null,null);break;default:void 0!==i&&(o=new Ve(i,t,t))}this._ssStruct=o,t._secondary=o,o&&e.structures.push(o)}}},{key:"_updateMolecules",value:function(e){var t=e.entityList;if(t)for(var r=e.chainsPerModel[0],n=0;n=r)){var c=this._complex._chains[l];a=a.concat(c._residues.slice())}}var u=new zs(this._complex,i.description,n+1);u.residues=a,this._complex._molecules[n]=u}}},{key:"_traverse",value:function(e){var t=this,r=this._complex.metadata;r.id=e.structureId,r.title=[],r.title[0]=e.title,r.date=e.releaseDate,r.format="mmtf";var n={onModel:function(e){t._onModel(e)},onChain:function(e){t._onChain(e)},onGroup:function(e){t._onGroup(e)},onAtom:function(e){t._onAtom(e)},onBond:function(e){t._onBond(e)}};this._ssType=-1,this._ssStruct=null,this._ssStart=null,ks.traverse(e,n),this._updateSecStructure(this._complex),this._updateMolecules(e)}},{key:"_linkAtomsToResidues",value:function(){for(var e=0;e=t))for(var a=this._complex._chains[o],s=0;s=l||Hs(e.charCodeAt(a+1))))return++f,void++a;if(u&&59===c){s=a;var r=0;do{if(-1===(s=Ws(10,e,s+1)))throw new js("Unterminated text block found",h,f);++r}while(s+1=l);return t=e.substring(a+1,s).replace(/\r/g,""),a=s+2,h+=r,f=1,u=!1,t}if(39===c||34===c){s=a;do{if(-1===(s=Ws(c,e,s+1)))throw new js("Unterminated quoted string found",h,f)}while(s+10){for(var w=0;w0&&h.addChain(r[v])}h.matrices=f,e.units.push(h)}}}}}],[{key:"canProbablyParse",value:function(e){return(0,n.isString)(e)&&/^\s*data_/i.test(e)}}]),r}(os);al.formats=["cif","mmcif"],al.extensions=[".cif",".mmcif"];var sl=function(){function e(){a(this,e),Se(this,"_xyz2crs",[]),Se(this,"_origin",new i.Pa4(0,0,0)),this._header={},this._boxSize=new i.Pa4,this._boxStart=new i.Pa4,this._header.delta={},this._header.extent=[],this._header.nstart=[],this._header.grid=[],this._header.crs2xyz=[],this._header.cellDims=new i.Pa4,this._header.angles=[],this._header.origin=new i.Pa4(0,0,0),this._header.dmin=0,this._header.dmean=0,this._header.dmax=0}return l(e,[{key:"_typedCheck",value:function(){if((0,n.isTypedArray)(this._buff))this._buff=this._buff.buffer;else if(!(0,n.isArrayBuffer)(this._buff))throw new TypeError("Expected ArrayBuffer or TypedArray")}},{key:"_fillHeader",value:function(e,t){for(var r in e)if(e.hasOwnProperty(r))switch(e[r][0]){case 0:this._header[r]=t[e[r][1]][e[r][2]];break;case 2:this._parseArray(this._header[r],t[e[r][1]],e[r][2]);break;case 1:this._parseVector(this._header[r],t[e[r][1]],e[r][2]);break;case 3:this._header[r]=new Uint8Array(t[e[r][1]],4*[e[r][2]],4*[e[r][3]])}}},{key:"_parseVector",value:function(e,t,r){var n=[t[r],t[r+1],t[r+2]];e.x=n[0],e.y=n[1],e.z=n[2]}},{key:"_parseArray",value:function(e,t,r){e[0]=t[r],e[1]=t[r+1],e[2]=t[r+2]}},{key:"_parseHeader",value:function(e){}},{key:"_setAxisIndices",value:function(){}},{key:"_setOrigins",value:function(){}},{key:"_getAxis",value:function(){var e=this._header,t=e.cellDims.x/e.grid[0],r=e.cellDims.y/e.grid[1],n=e.cellDims.z/e.grid[2],o=v(e.angles,3),a=o[0],s=o[1],l=o[2],c=Math.cos(s),u=(Math.cos(a)-Math.cos(s)*Math.cos(l))/Math.sin(l),h=Math.sqrt(1-c*c-u*u);return[new i.Pa4(t,0,0),new i.Pa4(Math.cos(l)*r,Math.sin(l)*r,0),new i.Pa4(c*n,u*n,h*n)]}},{key:"_getXYZdim",value:function(){return[this._header.extent[this._xyz2crs[0]],this._header.extent[this._xyz2crs[1]],this._header.extent[this._xyz2crs[2]]]}},{key:"_getVolumeInfo",value:function(){var e=(0,n.pick)(this._header,["dmean","dmin","dmax","sd","delta"]);return e.obtuseAngle=this._header.angles.map((function(e){return Number(e>=Math.PI/2)})),e}},{key:"_setBoxParams",value:function(e,t,r){var n=this,o=0,a=0,s=v(this._header.angles,3),l=s[0],c=s[1];s[2]>=Math.PI/2&&(o+=Math.abs(t.x)),c>=Math.PI/2&&(o+=Math.abs(r.x)),l>=Math.PI/2&&(a+=Math.abs(r.y)),this._boxStart=new i.Pa4(this._origin.x-o,this._origin.y-a,this._origin.z),this._boxSize=new i.Pa4(Math.abs(e.x)+Math.abs(t.x)+Math.abs(r.x),Math.abs(t.y)+Math.abs(r.y),Math.abs(r.z));var u=function(e,t){return Math.abs(e[t])/n._boxSize[t]};this._header.delta.x=u(t,"x"),this._header.delta.y=u(r,"x"),this._header.delta.z=u(r,"y")}},{key:"_getXYZbox",value:function(){return new i.ZzF(this._boxStart.clone(),this._boxStart.clone().add(this._boxSize))}},{key:"_toXYZData",value:function(){}},{key:"parse",value:function(e){return this._parseHeader(e),this._setOrigins(),new hr(Float32Array,this._getXYZdim(),this._getXYZbox(),1,this._toXYZData(),this._getVolumeInfo())}}]),e}();function ll(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=d(e);if(t){var i=d(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return f(this,r)}}var cl={extent:[2,"u32",0],type:[0,"u32",3],nstart:[2,"i32",4],grid:[2,"u32",7],cellDims:[1,"f32",10],angles:[2,"f32",13],crs2xyz:[2,"i32",16],dmin:[0,"f32",19],dmax:[0,"f32",20],dmean:[0,"f32",21],ispg:[0,"u32",22],nsymbt:[0,"u32",23],lksflg:[0,"u32",24],customData:[3,"buffer",25,9],origin:[1,"f32",34],map:[3,"buffer",52,1],machine:[0,"u32",53],sd:[0,"f32",54],nlabel:[0,"f32",55],label:[3,"buffer",56,200]},ul=function(e){h(r,e);var t=ll(r);function r(){return a(this,r),t.apply(this,arguments)}return l(r,[{key:"_parseHeader",value:function(e){this._buff=e,this._typedCheck();var t={};t.u32=new Uint32Array(this._buff,0,56),t.i32=new Int32Array(this._buff,0,56),t.f32=new Float32Array(this._buff,0,56),t.buffer=this._buff;var r=this._header;this._fillHeader(cl,t),r.angles.forEach((function(e,t,r){r[t]*=Math.PI/180}))}},{key:"_setAxisIndices",value:function(){var e=this._header;0===e.cellDims.x&&0===e.cellDims.y&&0===e.cellDims.z&&e.cellDims.set(1,1,1);var t=this._header.crs2xyz;0===t[0]&&0===t[1]&&0===t[2]&&(t[0]=1,t[1]=2,t[2]=3);var r=this._xyz2crs;r[t[0]-1]=0,r[t[1]-1]=1,r[t[2]-1]=2}},{key:"_setOrigins",value:function(){var e=v(this._getAxis(),3),t=e[0],r=e[1],n=e[2];this._setAxisIndices();var i=this._header,o=this._xyz2crs;if(0===i.origin.x&&0===i.origin.y&&0===i.origin.z?(this._origin.addScaledVector(t,i.nstart[o[0]]),this._origin.addScaledVector(r,i.nstart[o[1]]),this._origin.addScaledVector(n,i.nstart[o[2]])):this._origin=i.origin,t.multiplyScalar(i.extent[o[0]]-1),r.multiplyScalar(i.extent[o[1]]-1),n.multiplyScalar(i.extent[o[2]]-1),2!==i.type)throw new Error("CCP4: Unsupported format ".concat(i.type));this._data=new Float32Array(this._buff,1024+i.nsymbt,i.extent[0]*i.extent[1]*i.extent[2]),this._setBoxParams(t,r,n)}},{key:"_toXYZData",value:function(){var e=this._header,t=this._data,r=this._xyz2crs,n=new Float32Array(t.length),i=this._getXYZdim(),o=i[0],a=i[1],s=0,l=[];for(l[2]=0;l[2]=this._strings.length?(this._currentStart=this._strings.length-1,this._currentStringIndx=this._strings.length-1):(this._currentStart=e,this._currentStringIndx=e)}},{key:"getNextString",value:function(){return this._strings[++this._currentStringIndx]}},{key:"getCurrentString",value:function(){return this._strings[this._currentStringIndx]}},{key:"getStringFromStart",value:function(e){return this._currentStringIndx=this._currentStart+e,this._strings[this._currentStart+e]}},{key:"findNextDataItem",value:function(){for(var e=this.getNextString(),t=!1;!(0,n.isUndefined)(e)&&"$$$$"!==e.trim();){if(e.match(/>\s+<(.*)>/)){t=!0;break}e=this.getNextString()}return t}},{key:"findNextCompoundStart",value:function(){for(var e=this.getCurrentString();!(0,n.isUndefined)(e)&&"$$$$"!==e.trim();)e=this.getNextString();return this.setStart(++this._currentStringIndx),this.probablyHaveDataToParse()}},{key:"probablyHaveDataToParse",value:function(){return this._currentStringIndx\s+<(.+)>.*/,kl=/.*($$$$).*|.*>\s+<(.+)>.*/,Pl=["name","id","title"],Tl={name:["PUBCHEM_IUPAC_TRADITIONAL_NAME",/PUBCHEM_(.+)_NAME/,/(.+)name/,/(.+)NAME/],id:["PUBCHEM_COMPOUND_CID","id","ID",/.*CID/,/.*ID/,/.*id/],title:["msg","MSG","message","title","description","desc"]},Ml=function(e){h(s,e);var t,r,o=(t=s,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function s(e,t){var r;return a(this,s),(r=o.call(this,e,t))._format="sdf",r._complex=null,r._chain=null,r._residue=null,r._molecules=null,r._metadata={},r._metadata.molecules=[],r._currentMolProps={},r._compoundIndx=-1,r._assemblies=[],r._atomsParsed=0,r._atomsIndexes=[],r}return l(s,[{key:"canProbablyParse",value:function(e){return(0,n.isString)(e)&&El.test(e)}},{key:"_parseHeader",value:function(e){var t={};t.name=e.getStringFromStart(0);var r=parseInt(e.getStringFromStart(1).substr(10,6).trim(),10);t.date=r.toString()||"",t.title=e.getStringFromStart(2),this._metadata.molecules.push(t)}},{key:"_parseAtoms",value:function(e,t){var r,n=this._atomsParsed,o=function(e){if(!e)return"A";for(var t=[];e;)t.push(65+e%26),e=Math.trunc(e/26);return t.length>1&&(t.reverse(),t[0]-=1),String.fromCharCode.apply(String,t)}(this._compoundIndx);this._chain=this._complex.getChain(o)||this._complex.addChain(o),this._residue=this._chain.addResidue("UNK",1," ");for(var a=0;ao){var s=[o,i];i=s[0],o=s[1]}this._complex.addBond(i,o,Rl[a]||1,Al[a]||wl.BondType.UNKNOWN,!0)}}},{key:"_parseMOL",value:function(e){this._compoundIndx++,this._parseHeader(e);var t=e.getStringFromStart(3),r=parseInt(t.substr(0,3),10),n=parseInt(t.substr(3,3),10);this._parseAtoms(e,r),this._parseBonds(e,n),this._atomsParsed+=r,this._metadata.molecules[this._compoundIndx]._residues=[],this._metadata.molecules[this._compoundIndx]._residues.push(this._residue)}},{key:"_parseDataItem",value:function(e){for(var t=e.getCurrentString(),r=[],n=e.getNextString();""!==n.trim();)r.push(n),n=e.getNextString();1===r.length&&(r=v(r,1)[0]),this._currentMolProps[t.replace(/[<>]/g,"").trim()]=r}},{key:"_parseCompound",value:function(e){if(this._parseMOL(e),"sdf"===this._format){for(this._currentMolProps={};e.findNextDataItem();)this._parseDataItem(e);if(0!==Object.keys(this._currentMolProps).length){var t=this._metadata.molecules[this._compoundIndx];t.props=this._currentMolProps,this._tryToUpdateMoleculeData(t)}}}},{key:"_fixBondsArray",value:function(){for(var e=this._serialAtomMap,t=this._complex._bonds,r=0;r1){t.molecules=[];for(var n=0;n>8&255}if(100!==t.i16[18])throw new Error("DSN6: Incorrect format ");var o=this._header;this._fillHeader(Il,t),o.cellDims.multiplyScalar(1/o.scaleFactor),o.angles.forEach((function(e,t,r){r[t]*=Math.PI/180/o.scaleFactor})),o.div/=100}},{key:"_setAxisIndices",value:function(){this._xyz2crs[0]=0,this._xyz2crs[1]=1,this._xyz2crs[2]=2}},{key:"_setOrigins",value:function(){var e=this._header,t=v(this._getAxis(),3),r=t[0],n=t[1],i=t[2];this._setAxisIndices(),this._origin.addScaledVector(r,e.nstart[0]),this._origin.addScaledVector(n,e.nstart[1]),this._origin.addScaledVector(i,e.nstart[2]),r.multiplyScalar(e.extent[0]),n.multiplyScalar(e.extent[1]),i.multiplyScalar(e.extent[2]),this._setBoxParams(r,n,i)}},{key:"_pointCalculate",value:function(e,t,r,n,i,o,a){var s=this._header;return in&&(n=e[i]);this._header.sd=Math.sqrt(t/e.length),this._header.dmax=n,this._header.dmin=r}}]),r}(sl),Ll=function(e){h(r,e);var t=Nl(r);function r(e,n){var i;return a(this,r),(i=t.call(this,e,n))._options.fileType="dsn6",i.model=new Ol,i}return l(r,[{key:"parseSync",value:function(){return this.model.parse(this._data)}}],[{key:"canParse",value:function(e,t){return!!e&&e instanceof ArrayBuffer&&os.checkDataTypeOptions(t,"dsn6")}},{key:"canProbablyParse",value:function(e){return!1}}]),r}(os);Ll.formats=["dsn6"],Ll.extensions=[".dsn6",".omap"],Ll.binary=!0;var Bl=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(e){var t;return a(this,i),(t=n.call(this,e))._next=-1,t.next(),t}return l(i,[{key:"getNext",value:function(){return this._next}}]),i}(cs);var Dl=dr.Complex,zl=dr.Element,Fl=dr.Molecule,Vl=function(e){h(s,e);var t,r,o=(t=s,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function s(e,t){var r;return a(this,s),(r=o.call(this,e,t))._time=null,r._numAtoms=null,r._residueNumber=null,r._residueName="",r._atomName="",r._atomNumber=null,r._atomPosition=[],r._atomVelocity=[],r._complex=null,r._molecules=[],r._molecule=null,r._options.filetype="gro",r}return l(s,[{key:"canProbablyParse",value:function(e){return(0,n.isString)(this._data)&&/^\s*[^\n]*\n\s*\d+ *\n\s*\d+[^\n\d]{3}\s*\w+\s*\d+\s*-?\d/.test(e)}},{key:"_parseTitle",value:function(e){var t=this._complex.metadata;t.id=e.readLine().trim(),t.name=t.id.slice(t.id.lastIndexOf("\\")+1,t.id.lastIndexOf(".")),t.format="gro"}},{key:"_parseNumberOfAtoms",value:function(e){if(this._numAtoms=e.readInt(0,e.getNext()),Number.isNaN(this._numAtoms))throw new Error("Line 2 is not representing atom number. Consider checking input file")}},{key:"_parseAtom",value:function(e){this._residueNumber=e.readInt(1,5),this._residueName=e.readString(6,10).trim(),this._atomName=e.readString(11,15).trim(),this._atomNumber=e.readInt(16,20);var t=10*e.readFloat(21,28),r=10*e.readFloat(29,36),n=10*e.readFloat(37,45);if(Number.isNaN(t)||Number.isNaN(r)||Number.isNaN(n))this._complex.error={message:'Atom position is invalid in "'.concat(e.readLine(),'"')};else{var o=zl.getByName(this._atomName[0]);if("Unknown"!==o.fullName){var a=zl.Role[this._atomName],s=this._chain;s||(this._chain=s=this._complex.addChain("A"));var l=this._residue;l&&l.getSequence()===this._residueNumber||(this._residue=l=s.addResidue(this._residueName,this._residueNumber," ")),this._atomPosition=new i.Pa4(t,r,n),l.addAtom(this._atomName,o,this._atomPosition,a,!0,this._atomNumber," ",1,1,0)}else this._complex.error={message:"".concat(this._atomName[0]," hasn't been recognised as an atom name.")}}}},{key:"_finalize",value:function(){var e=new Fl(this._complex,this._complex.metadata.name,1);e.residues=this._chain._residues,e._chains=this._chain,this._complex._molecules[0]=e,this._molecules.push(e),this._complex.finalize({needAutoBonding:!0,detectAromaticLoops:this.settings.now.aromatic,enableEditing:this.settings.now.editing,serialAtomMap:this._serialAtomMap})}},{key:"parseSync",value:function(){var e=this._complex=new Dl,t=new Bl(this._data),r=0;for(this._parseTitle(t),t.next(),this._parseNumberOfAtoms(t),t.next(),r=0;r".concat(e)))return;this._currPosIdx++}this._toStringFromStart(0,t)}},{key:"_toStringFromHeader",value:function(e,t,r){this._toHeaderString(e,r);var n=this._currPosIdx+t;r[this._currPosIdx].match("@".concat(e))&&n=t.length?this._currStartIdx=this._currPosIdx=t.length-1:this._currStartIdx=this._currPosIdx=e}},{key:"_probablyHaveDataToParse",value:function(e){return this._currPosIdxMOLECULE>"!==e[this._currPosIdx].trim();)this._currPosIdx++;return this._setStart(++this._currPosIdx,e),this._probablyHaveDataToParse(e)}},{key:"_parseMolecule",value:function(e){this._toHeaderString("MOLECULE",e);var t=this._complex.metadata;t.name=e[++this._currPosIdx],t.format="mol2",this._molecule={_index:"",_chains:[]},this._molecule._index=this._compoundIndx+1,this._molecules.push(this._molecule)}},{key:"_parseAtoms",value:function(e,t){this._toHeaderString("ATOM",t);for(var r=0;r=9&&(h=parseFloat(n[8])||0);var f=this._chain;if(f||(this._chain=f=this._complex.getChain("A")||this._complex.addChain("A"),this._residue=null),this._setResidue(n)){var d=Gl.getByName(u),p=Gl.Role[a],m=new i.Pa4(s,l,c);this._residue.addAtom(a,d,m,p,!1,o," ",1,0,h)}}}},{key:"_setResidue",value:function(e){var t=1,r="UNK";if(e.length>=7&&(t=parseInt(e[6],10)),e.length>=8&&"<0>"!==e[7]&&(r=e[7].replace(Xl,"")),this.settings.now.nowater&&("HOH"===r||"WAT"===r))return!1;var n=this._residue,i=this._chain;return n&&n.getSequence()===t||(this._residue=i.addResidue(r,t,"A")),!0}},{key:"_parseBonds",value:function(e,t){this._toHeaderString("BOND",t);for(var r=0;ro){var s=[o,i];i=s[0],o=s[1]}this._complex.addBond(i,o,Wl[a]||0,Yl[a]||jl.BondType.UNKNOWN,!0)}}},{key:"_fixSerialAtoms",value:function(){for(var e=this._complex._atoms,t=0;t0&&void 0!==arguments[0]?arguments[0]:[];return a(this,i),n.call(this,e,["formats"])}return l(i,[{key:"find",value:function(e){var t=[];return e.format&&(t=this._dict.formats[e.format.toLowerCase()]||[]),Pr(t)}}]),i}(Mr),Jl=function(){function e(t,r){a(this,e),this._source=t,this._options=r||{},this._abort=!1}return l(e,[{key:"exportSync",value:function(){throw new Error("Exporting to this source is not implemented")}},{key:"export",value:function(){var e=this;return new Promise((function(t,r){setTimeout((function(){try{return e._abort?r(new Error("Export aborted")):t(e.exportSync())}catch(e){return r(e)}}))}))}},{key:"abort",value:function(){this._abort=!0}}]),e}();Nr(Jl.prototype);var ec=function(){function e(){a(this,e),this._resultArray=[],this._currentStr=-1,this._tag=null,this._fixedNumeration=!1,this._numeration=!1,this._tagStrNum=0}return l(e,[{key:"getResult",value:function(){return this.writeString("\n",81,81),this._resultArray.join("")}},{key:"_currentStrLength",value:function(){var e=this._resultArray[this._currentStr];return e?e.length:0}},{key:"newTag",value:function(e,t){this._tag=e||null,(0,n.isUndefined)(t)?(this._numeration=!1,this._fixedNumeration=!1,this._tagStrNum=0):(0,n.isNumber)(t)?(this._tagStrNum=t,this._numeration=!0,this._fixedNumeration=!0):(0,n.isBoolean)(t)&&(this._tagStrNum=0,this._numeration=t,this._fixedNumeration=!1)}},{key:"newString",value:function(e){this.writeString("\n",81,81),this._currentStr++,this._resultArray.push(""),e?this.writeString(e,1,6):this._tag&&this.writeString(this._tag,1,6),this._numeration&&(this._fixedNumeration||this._tagStrNum++,1!==this._tagStrNum&&this.writeString(this._tagStrNum.toString(),10,8))}},{key:"writeEntireString",value:function(e,t,r){t||(t=81);for(var n=0;nMath.abs(t-r)+1&&(i=i.substr(0,Math.abs(t-r+1))),l>a+1)this._resultArray[this._currentStr]+=" ".repeat(l-a-1);else if(l<=a){var c=this._resultArray[this._currentStr];this._resultArray[this._currentStr]=c.slice(0,l-1)}r(o=this._resultArray[this._currentStr]).length&&(this._resultArray[this._currentStr]+=" ".repeat(s-o.length))}}},{key:"writeBondsArray",value:function(e,t){for(var r=this._getSubArrays(e,4),n=0;n1||t[r].name.length>3?13:14;e.writeString(t[r].serial,11,7),e.writeString(t[r].name,i,16),e.writeString(String.fromCharCode(t[r].location),17,17),e.writeString(t[r].residue._type._name,20,18),e.writeString(t[r].residue._chain._name,22,22),e.writeString(t[r].residue._sequence,26,23),e.writeString(t[r].residue._icode,27,27),e.writeString(t[r].position.x.toFixed(3),38,31),e.writeString(t[r].position.y.toFixed(3),46,39),e.writeString(t[r].position.z.toFixed(3),54,47),e.writeString(t[r].occupancy.toFixed(2),60,55),e.writeString(t[r].temperature.toFixed(2),66,61),e.writeString(t[r].element.name,78,77),t[r].charge&&e.writeString(t[r].charge,79,80)}}},{key:"_extractCOMPND",value:function(e){if(this._source._molecules){var t=this._source._molecules;e.newTag("COMPND",!0);for(var r=0;r0&&(d=new uc).init(e.geometry,f);var p=f.addPerCylinder*f.needToSplit,m=n.count,v=s.count;c.init(u*m+p,u*v);for(var y=new i.yGw,_=new i.yGw,g=new i.Ilk,x=new i.Ilk,b={},w=0;w1e-7||Math.abs(r[s+1]-n[s+1])>1e-7||Math.abs(r[s+2]-n[s+2])>1e-7;o[l]=c,a+=c}return{is2Colored:o,needToSplit:a,addPerCylinder:e.getGeoParams().radialSegments}}},{key:"_collectInstancedGeoInfo",value:function(e){e.geometry instanceof Dr?this._collectSpheresInfo(e):e.geometry instanceof Qr&&this._collectCylindersInfo(e)}},{key:"_collectMaterialInfo",value:function(e){var t=e.material.uberOptions;return{diffuse:t.diffuse.toArray(),opacity:t.opacity,shininess:t.shininess,specular:t.specular.toArray()}}},{key:"_getCylinderInstanceMatrix",value:function(e,t,r){var n=e.attributes.matVector1.array,i=e.attributes.matVector2.array,o=e.attributes.matVector3.array,a=4*t;r.set(n[a],n[a+1],n[a+2],n[a+3],i[a],i[a+1],i[a+2],i[a+3],o[a],o[a+1],o[a+2],o[a+3],0,0,0,1)}},{key:"_getSphereInstanceMatrix",value:function(e,t,r){var n=e.attributes.offset,i=t*n.itemSize,o=n.array[i],a=n.array[i+1],s=n.array[i+2],l=n.array[i+3];r.set(l,0,0,o,0,l,0,a,0,0,l,s,0,0,0,1)}}]),e}(),fc=function(){function e(){a(this,e),this._resultArray=[],this._info=null}return l(e,[{key:"getResult",value:function(e){return this._info=e,this._resultArray.push(this._writeHeader()),this._resultArray.push(this._writeDefinitions()),this._resultArray.push(this._writeObjects(e.models,e.materials)),this._resultArray.push(this._writeRelations()),this._resultArray.push(this._writeConnections()),this._info=null,this._resultArray.join("")}},{key:"_writeHeader",value:function(){var e=new Date,t="Miew FBX Exporter v".concat(this._info.version);return"; FBX 6.1.0 project file\n; Created by ".concat(t," Copyright (c) 2015-2020 EPAM Systems, Inc.\n; For support please contact [email protected]\n; ----------------------------------------------------\n\nFBXHeaderExtension: {\n FBXHeaderVersion: ").concat(1003,"\n FBXVersion: ").concat(6100,"\n CreationTimeStamp: {\n Version: ").concat(1e3,"\n Year: ").concat(e.getFullYear(),"\n Month: ").concat(e.getMonth()+1," \n Day: ").concat(e.getDate(),"\n Hour: ").concat(e.getHours(),"\n Minute: ").concat(e.getMinutes(),"\n Second: ").concat(e.getSeconds(),"\n Millisecond: ").concat(e.getMilliseconds(),'\n }\n Creator: "').concat(t,'"\n OtherFlags: {\n FlagPLE: 0\n }\n}\nCreationTime: "').concat(e,'"\nCreator: "').concat(t,'" \n')}},{key:"_writeDefinitions",value:function(){return"\n; Object definitions\n;------------------------------------------------------------------\n\n".concat('\nDefinitions: {\n Version: 100\n Count: 3\n ObjectType: "Model" {\n Count: 1\n }\n ObjectType: "Geometry" {\n Count: 1\n }\n ObjectType: "Material" {\n Count: 1\n }\n ObjectType: "Pose" {\n Count: 1\n }\n ObjectType: "GlobalSettings" {\n Count: 1\n }\n} ',"\n")}},{key:"_models",value:function(){for(var e="",t=this._info.models,r=0;r-t.near?"hidden":"visible",l=1e4*(t.far- -this._vector.z)/(t.far-t.near),c=e.getElement();if(void 0===r.fog)c.style.color=o(e.userData.color),"transparent"!==e.userData.background&&(c.style.background=o(e.userData.background));else{var u=i.M8C.smoothstep(-this._vector.z,r.fog.near,r.fog.far);c.style.color=n(e.userData.color,r.fog.color,u),"transparent"!==e.userData.background&&(c.style.background=n(e.userData.background,r.fog.color,u))}this._vector.applyMatrix4(this._projectionMatrix);var h="".concat(e.userData!=={}?e.userData.translation:"translate(-50%, -50%) ","translate(").concat(this._vector.x*this._widthHalf+this._widthHalf,"px,").concat(-this._vector.y*this._heightHalf+this._heightHalf,"px)");c.style.visibility=s,c.style.WebkitTransform=h,c.style.MozTransform=h,c.style.oTransform=h,c.style.transform=h,c.style.zIndex=Number(l).toFixed(0),c.parentNode!==this._domElement&&this._domElement.appendChild(c)}for(var f=0,d=e.children.length;f0&&(this._altObj.setObjects(a.objects),this._altObj.pivot=a.pivot,"axis"in a?this._altObj.axis=a.axis.clone():this._altObj.axis.set(0,0,1),Ec.set(o*n,o*i),this._altObj.translate(Ec),this.dispatchEvent({type:"change",action:"translate"}))}}this._lastUpdateTime=e}),Lc.prototype.reset=function(){this._state=Mc,this.object.quaternion.copy(Nc.set(0,0,0,1))},Lc.prototype.mousedown=function(e){if(!1!==this.enabled&&this._state===Mc){if(e.preventDefault(),e.stopPropagation(),this._state===Mc)if(0===e.button){this._affectedObj.stop();var t=!1;if(e.altKey){var r=this.getAltObj();(t=r.objects.length>0)&&(this._altObj.setObjects(r.objects),this._altObj.pivot=r.pivot,"axis"in r?this._altObj.axis=r.axis.clone():this._altObj.axis.set(0,0,1))}this._affectedObj=t?this._altObj:this._mainObj,this._state=t&&e.ctrlKey&&this._isTranslationAllowed?1:0}else 2===e.button&&(this._state=3);0===this._state&&(this.convertMouseToOnCircle(this._mouseCurPos,e.pageX,e.pageY),this._mousePrevPos.copy(this._mouseCurPos)),1!==this._state&&3!==this._state||(this.convertMouseToViewport(this._mouseCurPos,e.pageX,e.pageY),this._mousePrevPos.copy(this._mouseCurPos))}},Lc.prototype.mousemove=function(e){if(!1!==this.enabled&&this._state!==Mc)switch(e.preventDefault(),e.stopPropagation(),this._state){case 0:this._mousePrevPos.copy(this._mouseCurPos),this.convertMouseToOnCircle(this._mouseCurPos,e.pageX,e.pageY),this.rotateByMouse(e.altKey&&!this._isAltObjFreeRotationAllowed||e.shiftKey),this._lastMouseMoveTime=this._clock.getElapsedTime();break;case 1:this._mousePrevPos.copy(this._mouseCurPos),this.convertMouseToViewport(this._mouseCurPos,e.pageX,e.pageY),this.translate();break;case 3:this._mousePrevPos.copy(this._mouseCurPos),this.convertMouseToViewport(this._mouseCurPos,e.pageX,e.pageY),this.translatePivotByMouse()}},Lc.prototype.mousewheel=function(e){if(!1!==this.enabled&&J.now.zooming&&this._state===Mc&&!e.shiftKey){e.preventDefault();var t=0;e.wheelDelta?t=e.wheelDelta/40:e.detail&&(t=-e.detail/3);var r=1+.05*t;r=Math.max(r,.01),this.scale(r)}},Lc.prototype.mouseup=function(e){!1!==this.enabled&&this._state!==Mc&&(e.preventDefault(),e.stopPropagation(),this._state=Mc,this._clock.getElapsedTime()-this._lastMouseMoveTime>.1&&this._affectedObj.stop())},Lc.prototype.touchstartend=function(e){if(!1!==this.enabled)switch(e.preventDefault(),e.stopPropagation(),e.touches.length){case 1:this._state=0,this.convertMouseToOnCircle(this._mouseCurPos,e.touches[0].pageX,e.touches[0].pageY),this._mousePrevPos.copy(this._mouseCurPos);break;case 2:this._mainObj.stop(),this._altObj.stop(),this._state=2;var t=e.touches[0].pageX-e.touches[1].pageX,r=e.touches[0].pageY-e.touches[1].pageY;this._touchDistanceCur=this._touchDistanceStart=Math.sqrt(t*t+r*r),this._scaleStart=this.object.scale.x;break;default:this._state=Mc}},Lc.prototype.touchmove=function(e){if(!1!==this.enabled&&this._state!==Mc)switch(e.preventDefault(),e.stopPropagation(),this._state){case 0:this._mousePrevPos.copy(this._mouseCurPos),this.convertMouseToOnCircle(this._mouseCurPos,e.touches[0].pageX,e.touches[0].pageY),this.rotateByMouse(!1),this._lastMouseMoveTime=this._clock.getElapsedTime();break;case 2:if(J.now.zooming){var t=e.touches[0].pageX-e.touches[1].pageX,r=e.touches[0].pageY-e.touches[1].pageY;this._touchDistanceCur=Math.sqrt(t*t+r*r);var n=this._scaleStart*this._touchDistanceCur/this._touchDistanceStart/this.object.scale.x;this.scale(n)}}},Lc.prototype.keydownup=function(e){if(!1!==this.enabled&&!1!==this.hotkeysEnabled)switch(e.keyCode){case 37:case 38:case 39:case 40:this._pressedKeys[e.keyCode]="keydown"===e.type,e.preventDefault(),e.stopPropagation()}},Lc.prototype.getKeyBindObject=function(){return window.top},Lc.prototype.dispose=function(){for(var e=0;e=524288?e-1048576:e}var Gc=function(){function e(t,r,n){a(this,e),this._complex=t,this._secondary=null,this.isLoading=!1,this._framesRange={start:0,end:-1},this.frameIsReady=!1,this._buffer=null,this._frameRequest=null,this._callbacks=n,"function"==typeof r?(this._framesRequestLength=1,this._downloadDataFn=r):this.parseBinaryData(r,!0),this.reset(),this.setFrame(0)}return l(e,[{key:"_prepareBuffer",value:function(e,t){if(null==e&&(e=0),null==t&&(t=e+this._framesRequestLength),void 0!==this._framesCount&&(t=Math.min(this._framesCount-1,t)),this._downloadDataFn){var r=this;this._buffer||(this._buffer={}),this._buffer.state="downloading",this.isLoading=!0,r._callbacks&&"function"==typeof r._callbacks.onLoadStatusChanged&&r._callbacks.onLoadStatusChanged(),this._downloadDataFn({start:e,end:t+1},(function(n){if(r.isLoading=!1,r._callbacks&&"function"==typeof r._callbacks.onLoadStatusChanged&&r._callbacks.onLoadStatusChanged(),r._buffer={data:n,state:"ready",start:e,end:t},null!==r._frameRequest){var i=r._frameRequest;r._frameRequest=null,r.setFrame(i)}}),(function(){r.isLoading=!1,r._callbacks&&"function"==typeof r._callbacks.onError&&r._callbacks.onError("Streaming failed")}))}}},{key:"_parseBuffer",value:function(){if(this._buffer&&"ready"===this._buffer.state){this._framesRange={start:this._buffer.start,end:this._buffer.end},this.parseBinaryData(this._buffer.data,!1);var e=(this._buffer.end+1)%this._framesCount;if(e>=this._framesCount&&(e=0),this._buffer={state:"none"},this._prepareBuffer(e,e+this._framesRequestLength),null!==this._frameRequest){var t=this._frameRequest;this._frameRequest=null,this.setFrame(t)}}}},{key:"parseBinaryData",value:function(e){var t=new DataView(e),r=0,n=t.getUint32(r,!0);r+=4;var i=t.getUint32(r,!0);this._framesCount=i,this._framesRange.end=this._framesRange.end>0?Math.min(this._framesRange.end,i-1):i-1,r+=4,this._atomsCount=n,this._framesRequestLength=Math.ceil(1048576/(8*n));var o=this._framesRange.end-this._framesRange.start+1;if(n!==this._complex._atoms.length||e.byteLength!==12+o*n*8)throw new Error;for(var a=this._complex,s=t.getUint32(r,!0),l=0;s>1e3&&l>>28,_=Uc((268435200&v)>>>8>>0),g=Uc(((255&v)<<12|(4293918720&m)>>>20)>>0),x=Uc((1048575&m)>>0);f[p]=0,y>0&&y<4?f[p]=1:4===y&&(f[p]=2),u[h++]=_/100,u[h++]=g/100,u[h++]=x/100}c.push(Vc(f,a))}this._secondaryData=c,this._data=u}},{key:"nextFrame",value:function(){this.setFrame((this._currFrame+1)%this._framesCount)}},{key:"needsColorUpdate",value:function(e){return e instanceof ca}},{key:"getAtomColor",value:function(e,t){return e.getResidueColor(this._residues[t.residue._index],this._complex)}},{key:"getResidueColor",value:function(e,t){return e.getResidueColor(this._residues[t._index],this._complex)}},{key:"_updateSecondary",value:function(){var e,t=this._residues,r=t.length;for(e=0;e=this._framesRange.start&&e<=this._framesRange.end)this._currFrame=e,this._cachedResidues=!1,this._updateSecondary(),this.frameIsReady=!0;else if(this._frameRequest=e,this._buffer)switch(this._buffer.state){case"none":this._prepareBuffer(e);break;case"ready":this._parseBuffer()}else this._prepareBuffer(e)}},{key:"disableEvents",value:function(){this._callbacks=null}},{key:"getAtomPos",value:function(t){var r=e._vec,n=this,i=n._data,o=3*(n._atomsCount*(n._currFrame-n._framesRange.start)+t);return r.set(i[o],i[o+1],i[o+2]),r}},{key:"getResidues",value:function(){return this._cachedResidues||this._complex.updateToFrame(this),this._residues}}]),e}();Se(Gc,"_vec",new i.Pa4);var jc=function(){function e(t,r){if(a(this,e),this.constructor===e)throw new Error("Can not instantiate abstract class!");this.params=t,this.opts=(0,n.merge)($.deriveDeep(J.now.objects[this.type],!0),r),this.needsRebuild=!1,this._mesh=null,this.id=null}return l(e,[{key:"identify",value:function(){var e={type:this.type,params:this.params},t=$.objectsDiff(this.opts,J.now.modes[this.id]);return(0,n.isEmpty)(t)||(e.opts=t),e}},{key:"toString",value:function(){return"o=".concat(this.type,",").concat(this.params.join(","))+$.compareOptionsWithDefaults(this.opts,J.defaults.objects[this.type])}},{key:"getGeometry",value:function(){return this._mesh}},{key:"destroy",value:function(){this._mesh&&Ar.destroyObject(this._mesh)}}]),e}();jc.prototype.type="__";var Hc=function(e){h(o,e);var t,r,n=(t=o,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function o(e,t){var r;if(a(this,o),r=n.call(this,e,t),e.length<2)throw new Error("Wrong number of argumets on line object creation!");var i=v(e,2);return r._id1=i[0],r._id2=i[1],r}return l(o,[{key:"_getAtomFromName",value:function(e,t){var r=e.getAtomByFullname(t);if(!r)throw new Error(t+" - Wrong atom format it must be '#CHAIN_NAME.#RESIDUE_NUMBER.#ATOM_NAME' (e.g. 'A.38.CO1')");return r}},{key:"build",value:function(e){var t=new i.u9r;this._atom1=this._getAtomFromName(e,this._id1),this._atom2=this._getAtomFromName(e,this._id2);var r=this._atom1.position,n=this._atom2.position,o=new Float32Array([r.x,r.y,r.z,n.x,n.y,n.z]);t.setAttribute("position",new i.TlE(o,3)),t.computeBoundingBox();var a=new li;a.setValues({lights:!1,overrideColor:!0,dashedLine:!0,fogTransparent:J.now.bg.transparent}),this._line=new xi.Line(t,a),this._line.computeLineDistances(),this._line.material.setUberOptions({fixedColor:new i.Ilk(this.opts.color),dashedLineSize:this.opts.dashSize,dashedLinePeriod:this.opts.dashSize+this.opts.gapSize}),this._line.material.updateUniforms(),this._line.raycast=function(e,t){},this._mesh=this._line;var s=e.getTransforms();s.length>0&&(this._mesh=new i.ZAu,this._mesh.add(this._line),ka.applyTransformsToMeshes(this._mesh,s))}},{key:"updateToFrame",value:function(e){if(this._atom1&&this._atom2&&this._line){var t=this._line.geometry;t.vertices[0].copy(e.getAtomPos(this._atom1.index)),t.vertices[1].copy(e.getAtomPos(this._atom2.index)),this._line.computeLineDistances(),t.computeBoundingSphere(),t.verticesNeedUpdate=!0}}}]),o}(jc);Hc.prototype.constructor=Hc,Hc.prototype.type="line";var Wc=function(e){h(o,e);var t,r,n=(t=o,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function o(e){var t;a(this,o),t=n.call(this,e);var r={uniforms:{srcTex:{type:"t",value:null},srcDepthTex:{type:"t",value:null},srcTexSize:{type:"v2",value:new i.FM8(512,512)},color:{type:"v3",value:null},threshold:{type:"f",value:null},opacity:{type:"f",value:1},thickness:{type:"v2",value:new i.FM8(1,1)}},vertexShader:vr,fragmentShader:"precision highp float;\r\n\r\nuniform sampler2D srcTex;\r\nuniform vec2 srcTexSize;\r\nuniform vec2 thickness;\r\nvarying vec2 vUv;\r\n\r\n#ifdef DEPTH_OUTLINE\r\n uniform sampler2D srcDepthTex; //depthTexture\r\n uniform vec3 color;\r\n uniform float threshold;\r\n#endif\r\n\r\nvoid main() {\r\n\r\n vec2 pixelSize = thickness / srcTexSize;\r\n\r\n #ifdef DEPTH_OUTLINE\r\n float c00 = texture2D(srcDepthTex, vUv + vec2(-pixelSize.x,-pixelSize.y)).x;\r\n float c01 = texture2D(srcDepthTex, vUv + vec2(0,-pixelSize.y)).x;\r\n float c02 = texture2D(srcDepthTex, vUv + vec2(pixelSize.x,-pixelSize.y)).x;\r\n float c10 = texture2D(srcDepthTex, vUv + vec2(-pixelSize.x,0)).x;\r\n float c12 = texture2D(srcDepthTex, vUv + vec2(pixelSize.x,0)).x;\r\n float c20 = texture2D(srcDepthTex, vUv + vec2(-pixelSize.x,pixelSize.y)).x;\r\n float c21 = texture2D(srcDepthTex, vUv + vec2(0,pixelSize.y)).x;\r\n float c22 = texture2D(srcDepthTex, vUv + vec2(pixelSize.x,pixelSize.y)).x;\r\n\r\n float horizEdge = - c00 - 2.0 * c01 - c02 + c20 + 2.0 * c21 + c22;\r\n float vertEdge = - c00 - 2.0 * c10 - c20 + c02 + 2.0 * c12 + c22;\r\n\r\n float grad = sqrt(horizEdge * horizEdge + vertEdge * vertEdge);\r\n\r\n gl_FragColor = ( grad > threshold ) ? vec4(color.rgb, 1.0) : gl_FragColor = texture2D(srcTex, vUv);\r\n\r\n #else\r\n vec4 c00 = texture2D(srcTex, vUv + vec2(-pixelSize.x,-pixelSize.y));\r\n vec4 c01 = texture2D(srcTex, vUv + vec2(0,-pixelSize.y));\r\n vec4 c02 = texture2D(srcTex, vUv + vec2(pixelSize.x,-pixelSize.y));\r\n vec4 c10 = texture2D(srcTex, vUv + vec2(-pixelSize.x,0));\r\n vec4 c12 = texture2D(srcTex, vUv + vec2(pixelSize.x,0));\r\n vec4 c20 = texture2D(srcTex, vUv + vec2(-pixelSize.x,pixelSize.y));\r\n vec4 c21 = texture2D(srcTex, vUv + vec2(0,pixelSize.y));\r\n vec4 c22 = texture2D(srcTex, vUv + vec2(pixelSize.x,pixelSize.y));\r\n\r\n vec4 horizEdge = - c00 - 2.0 * c01 - c02 + c20 + 2.0 * c21 + c22;\r\n vec4 vertEdge = - c00 - 2.0 * c10 - c20 + c02 + 2.0 * c12 + c22;\r\n\r\n vec4 grad = sqrt(horizEdge * horizEdge + vertEdge * vertEdge);\r\n gl_FragColor = grad;\r\n #endif\r\n}\r\n",transparent:!0,depthTest:!1,depthWrite:!1};return t.setValues(r),t}return l(o,[{key:"copy",value:function(e){Ye(d(o.prototype),"copy",this).call(this,e),this.depth=e.depth}},{key:"setValues",value:function(e){if(void 0!==e){Ye(d(o.prototype),"setValues",this).call(this,e);var t={};this.depth&&(t.DEPTH_OUTLINE=1),this.defines=t}}}]),o}(i.FIo);Wc.prototype.depth=!1;var Yc=function(e){h(o,e);var t,r,n=(t=o,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function o(e){var t;return a(this,o),(t=n.call(this,e)).setValues({uniforms:{srcTex:{type:"t",value:null},srcTexelSize:{type:"v2",value:new i.FM8(1/512,1/512)},bgColor:{type:"c",value:new i.Ilk(16777215)}},vertexShader:vr,fragmentShader:"precision highp float;\r\n\r\n// edge end finding algorithm parameters\r\n#define FXAA_QUALITY_PS 8\r\n#define FXAA_QUALITY_P0 1.0\r\n#define FXAA_QUALITY_P1 1.5\r\n#define FXAA_QUALITY_P2 2.0\r\n#define FXAA_QUALITY_P3 2.0\r\n#define FXAA_QUALITY_P4 2.0\r\n#define FXAA_QUALITY_P5 2.0\r\n#define FXAA_QUALITY_P6 4.0\r\n#define FXAA_QUALITY_P7 12.0\r\n// constants\r\nfloat fxaaQualityEdgeThreshold = 0.125;\r\nfloat fxaaQualityEdgeThresholdMin = 0.0625;\r\nfloat fxaaQualitySubpix = 0.7; //0.65;\r\n// global params\r\nuniform sampler2D srcTex;\r\nuniform vec2 srcTexelSize;\r\nuniform vec3 bgColor;\r\n// from vs\r\nvarying vec2 vUv;\r\n//=====================================================================//\r\n// calc luminance from rgb\r\n//'float FxaaLuma(vec3 rgb) {return rgb.y * (0.587/0.299) + rgb.x; } // Lotte's idea about game luminance\r\nfloat FxaaLuma(vec3 rgb) {return dot(rgb, vec3(0.299, 0.587, 0.114)); } // real luminance calculation\r\n // for non-real scene rendering\r\n// texture sampling by pixel position(coords) and offset(in pixels)\r\n vec3 FxaaTex(sampler2D tex, vec2 pos, vec2 off, vec2 res ) {\r\n #ifdef BG_TRANSPARENT\r\n vec4 color = texture2D( tex, pos + off * res );\r\n return mix(color.rgb, bgColor, 1.0 - color.a);\r\n #else\r\n return texture2D( tex, pos + off * res ).xyz;\r\n #endif\r\n}\r\nvec3 FxaaTexTop(sampler2D tex, vec2 pos) {\r\n #ifdef BG_TRANSPARENT\r\n vec4 color = texture2D( tex, pos );\r\n return mix(color.rgb, bgColor, 1.0 - color.a);\r\n #else\r\n return texture2D( tex, pos).xyz;\r\n #endif\r\n}\r\nvec4 FxaaTexTopAlpha(sampler2D tex, vec2 pos) {\r\n return texture2D( tex, pos);\r\n}\r\n\r\n//=====================================================================//\r\nvoid main() {\r\n // renaming\r\n vec2 posM = vUv;\r\n // get luminance for neighbours\r\n float lumaS = FxaaLuma(FxaaTex(srcTex, posM, vec2( 0.0, 1.0 ), srcTexelSize));\r\n float lumaE = FxaaLuma(FxaaTex(srcTex, posM, vec2( 1.0, 0.0 ), srcTexelSize));\r\n float lumaN = FxaaLuma(FxaaTex(srcTex, posM, vec2( 0.0, -1.0 ), srcTexelSize));\r\n float lumaW = FxaaLuma(FxaaTex(srcTex, posM, vec2( -1.0, 0.0 ), srcTexelSize));\r\n float lumaM = FxaaLuma(FxaaTexTop(srcTex, posM));\r\n // find max and min luminance\r\n float rangeMax = max(max(lumaN, lumaW), max(lumaE, max(lumaS, lumaM)));\r\n float rangeMin = min(min(lumaN, lumaW), min(lumaE, min(lumaS, lumaM)));\r\n // calc maximum non-edge range\r\n float rangeMaxScaled = rangeMax * fxaaQualityEdgeThreshold;\r\n float range = rangeMax - rangeMin;\r\n float rangeMaxClamped = max(fxaaQualityEdgeThresholdMin, rangeMaxScaled);\r\n // exit when luma contrast is small (is not edge)\r\n if(range < rangeMaxClamped){\r\n gl_FragColor = FxaaTexTopAlpha(srcTex, posM);\r\n return;\r\n }\r\n float subpixRcpRange = 1.0/range;\r\n // note: the sampling coordinates can be calculated in vertex shader but the approach doesn't affect performance\r\n // visibly, thus we decided to leave calculation here for better readability.\r\n // calc other neighbours luminance\r\n float lumaNE = FxaaLuma(FxaaTex(srcTex, posM, vec2( 1.0, -1.0 ), srcTexelSize));\r\n float lumaSW = FxaaLuma(FxaaTex(srcTex, posM, vec2( -1.0, 1.0 ), srcTexelSize));\r\n float lumaSE = FxaaLuma(FxaaTex(srcTex, posM, vec2( 1.0, 1.0 ), srcTexelSize));\r\n float lumaNW = FxaaLuma(FxaaTex(srcTex, posM, vec2( -1.0, -1.0 ), srcTexelSize));\r\n/*--------------span calculation and subpix amount calulation-----------------*/\r\n float lumaNS = lumaN + lumaS;\r\n float lumaWE = lumaW + lumaE;\r\n float subpixNSWE = lumaNS + lumaWE;\r\n float edgeHorz1 = (-2.0 * lumaM) + lumaNS;\r\n float edgeVert1 = (-2.0 * lumaM) + lumaWE;\r\n/*--------------------------------------------------------------------------*/\r\n float lumaNESE = lumaNE + lumaSE;\r\n float lumaNWNE = lumaNW + lumaNE;\r\n float edgeHorz2 = (-2.0 * lumaE) + lumaNESE;\r\n float edgeVert2 = (-2.0 * lumaN) + lumaNWNE;\r\n/*--------------------------------------------------------------------------*/\r\n float lumaNWSW = lumaNW + lumaSW;\r\n float lumaSWSE = lumaSW + lumaSE;\r\n float edgeHorz4 = (abs(edgeHorz1) * 2.0) + abs(edgeHorz2);\r\n float edgeVert4 = (abs(edgeVert1) * 2.0) + abs(edgeVert2);\r\n float edgeHorz3 = (-2.0 * lumaW) + lumaNWSW;\r\n float edgeVert3 = (-2.0 * lumaS) + lumaSWSE;\r\n float edgeHorz = abs(edgeHorz3) + edgeHorz4;\r\n float edgeVert = abs(edgeVert3) + edgeVert4;\r\n/*--------------------subpix amount calulation------------------------------*/\r\n float subpixNWSWNESE = lumaNWSW + lumaNESE;\r\n float lengthSign = srcTexelSize.x;\r\n bool horzSpan = edgeHorz >= edgeVert;\r\n // debug code edge span visualization\r\n/*' if (horzSpan)\r\n gl_FragColor = vec4(0.0, 0.0, 1.0, 1.0);\r\n else\r\n gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);\r\n return;*/\r\n float subpixA = subpixNSWE * 2.0 + subpixNWSWNESE;\r\n/*--------------------------------------------------------------------------*/\r\n if(!horzSpan) lumaN = lumaW;\r\n if(!horzSpan) lumaS = lumaE;\r\n if(horzSpan) lengthSign = srcTexelSize.y;\r\n float subpixB = (subpixA * (1.0/12.0)) - lumaM;\r\n/*--------------------------------------------------------------------------*/\r\n float gradientN = lumaN - lumaM;\r\n float gradientS = lumaS - lumaM;\r\n float lumaNN = lumaN + lumaM;\r\n float lumaSS = lumaS + lumaM;\r\n bool pairN = abs(gradientN) >= abs(gradientS);\r\n float gradient = max(abs(gradientN), abs(gradientS));\r\n if(pairN) lengthSign = -lengthSign;\r\n float subpixC = clamp(abs(subpixB) * subpixRcpRange, 0.0, 1.0);\r\n/*--------------------------------------------------------------------------*/\r\n vec2 posB;\r\n posB = posM;\r\n vec2 offNP;\r\n offNP.x = (!horzSpan) ? 0.0 : srcTexelSize.x;\r\n offNP.y = ( horzSpan) ? 0.0 : srcTexelSize.y;\r\n if(!horzSpan) posB.x += lengthSign * 0.5;\r\n if( horzSpan) posB.y += lengthSign * 0.5;\r\n/*--------------------------------------------------------------------------*/\r\n vec2 posN;\r\n posN = posB - offNP * FXAA_QUALITY_P0;\r\n vec2 posP;\r\n posP = posB + offNP * FXAA_QUALITY_P0;\r\n float subpixD = ((-2.0)*subpixC) + 3.0;\r\n float lumaEndN = FxaaLuma(FxaaTexTop(srcTex, posN));\r\n float subpixE = subpixC * subpixC;\r\n float lumaEndP = FxaaLuma(FxaaTexTop(srcTex, posP));\r\n/*--------------------------------------------------------------------------*/\r\n if(!pairN) lumaNN = lumaSS;\r\n float gradientScaled = gradient * 1.0/4.0;\r\n float lumaMM = lumaM - lumaNN * 0.5;\r\n float subpixF = subpixD * subpixE;\r\n bool lumaMLTZero = lumaMM < 0.0;\r\n/*---------------------looped edge-end search-------------------------------*/\r\n lumaEndN -= lumaNN * 0.5;\r\n lumaEndP -= lumaNN * 0.5;\r\n bool doneN = abs(lumaEndN) >= gradientScaled;\r\n bool doneP = abs(lumaEndP) >= gradientScaled;\r\n if(!doneN) posN -= offNP * FXAA_QUALITY_P1;\r\n bool doneNP = (!doneN) || (!doneP);\r\n if(!doneP) posP += offNP * FXAA_QUALITY_P1;\r\n/*--------------------------------------------------------------------------*/\r\n if(doneNP) {\r\n if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(srcTex, posN.xy));\r\n if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(srcTex, posP.xy));\r\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\r\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\r\n doneN = abs(lumaEndN) >= gradientScaled;\r\n doneP = abs(lumaEndP) >= gradientScaled;\r\n if(!doneN) posN -= offNP * FXAA_QUALITY_P2;\r\n doneNP = (!doneN) || (!doneP);\r\n if(!doneP) posP += offNP * FXAA_QUALITY_P2;\r\n/*--------------------------------------------------------------------------*/\r\n #if (FXAA_QUALITY_PS > 3)\r\n if(doneNP) {\r\n if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(srcTex, posN.xy));\r\n if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(srcTex, posP.xy));\r\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\r\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\r\n doneN = abs(lumaEndN) >= gradientScaled;\r\n doneP = abs(lumaEndP) >= gradientScaled;\r\n if(!doneN) posN -= offNP * FXAA_QUALITY_P3;\r\n doneNP = (!doneN) || (!doneP);\r\n if(!doneP) posP += offNP * FXAA_QUALITY_P3;\r\n/*--------------------------------------------------------------------------*/\r\n #if (FXAA_QUALITY_PS > 4)\r\n if(doneNP) {\r\n if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(srcTex, posN.xy));\r\n if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(srcTex, posP.xy));\r\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\r\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\r\n doneN = abs(lumaEndN) >= gradientScaled;\r\n doneP = abs(lumaEndP) >= gradientScaled;\r\n if(!doneN) posN -= offNP * FXAA_QUALITY_P4;\r\n doneNP = (!doneN) || (!doneP);\r\n if(!doneP) posP += offNP * FXAA_QUALITY_P4;\r\n/*--------------------------------------------------------------------------*/\r\n #if (FXAA_QUALITY_PS > 5)\r\n if(doneNP) {\r\n if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(srcTex, posN.xy));\r\n if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(srcTex, posP.xy));\r\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\r\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\r\n doneN = abs(lumaEndN) >= gradientScaled;\r\n doneP = abs(lumaEndP) >= gradientScaled;\r\n if(!doneN) posN -= offNP * FXAA_QUALITY_P5;\r\n doneNP = (!doneN) || (!doneP);\r\n if(!doneP) posP += offNP * FXAA_QUALITY_P5;\r\n/*--------------------------------------------------------------------------*/\r\n #if (FXAA_QUALITY_PS > 6)\r\n if(doneNP) {\r\n if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(srcTex, posN.xy));\r\n if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(srcTex, posP.xy));\r\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\r\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\r\n doneN = abs(lumaEndN) >= gradientScaled;\r\n doneP = abs(lumaEndP) >= gradientScaled;\r\n if(!doneN) posN -= offNP * FXAA_QUALITY_P6;\r\n doneNP = (!doneN) || (!doneP);\r\n if(!doneP) posP += offNP * FXAA_QUALITY_P6;\r\n/*--------------------------------------------------------------------------*/\r\n #if (FXAA_QUALITY_PS > 7)\r\n if(doneNP) {\r\n if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(srcTex, posN.xy));\r\n if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(srcTex, posP.xy));\r\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\r\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\r\n doneN = abs(lumaEndN) >= gradientScaled;\r\n doneP = abs(lumaEndP) >= gradientScaled;\r\n if(!doneN) posN -= offNP * FXAA_QUALITY_P7;\r\n doneNP = (!doneN) || (!doneP);\r\n if(!doneP) posP += offNP * FXAA_QUALITY_P7;\r\n/*--------------------------------------------------------------------------*/\r\n }\r\n #endif\r\n }\r\n #endif\r\n }\r\n #endif\r\n }\r\n #endif\r\n }\r\n #endif\r\n }\r\n/*----------------calculate subpix offset due to edge ends-------------------*/\r\n float dstN = posM.x - posN.x;\r\n float dstP = posP.x - posM.x;\r\n if(!horzSpan) dstN = posM.y - posN.y;\r\n if(!horzSpan) dstP = posP.y - posM.y;\r\n/*--------------------------------------------------------------------------*/\r\n bool goodSpanN = (lumaEndN < 0.0) != lumaMLTZero;\r\n float spanLength = (dstP + dstN);\r\n bool goodSpanP = (lumaEndP < 0.0) != lumaMLTZero;\r\n float spanLengthRcp = 1.0 / spanLength;\r\n/*--------------------------------------------------------------------------*/\r\n bool directionN = dstN < dstP;\r\n float dst = min(dstN, dstP);\r\n bool goodSpan = directionN ? goodSpanN : goodSpanP;\r\n float subpixG = subpixF * subpixF;\r\n float pixelOffset = (dst * (-spanLengthRcp)) + 0.5;\r\n float subpixH = subpixG * fxaaQualitySubpix;\r\n/*-----------------calc texture offest using subpix-------------------------*/\r\n float pixelOffsetGood = goodSpan ? pixelOffset : 0.0;\r\n float pixelOffsetSubpix = max(pixelOffsetGood, subpixH);\r\n\r\n float offset = pixelOffsetSubpix * lengthSign;\r\n #ifdef BG_TRANSPARENT\r\n // get original texel\r\n vec4 rgbaA = FxaaTexTopAlpha(srcTex, posM);\r\n // calc step to blended texel\r\n vec2 step = sign((!horzSpan) ? vec2 (offset, 0.0) : vec2 (0.0, offset));\r\n // get neighboring texel\r\n vec4 rgbaB = FxaaTexTopAlpha(srcTex, posM + step * srcTexelSize);\r\n // calc blend factor from offset\r\n float f = (!horzSpan) ? offset / srcTexelSize.x : offset / srcTexelSize.y;\r\n f = abs(f);\r\n // calc alpha (special formula to emulate blending with bg)\r\n gl_FragColor.a = 1.0 - mix(1.0 - rgbaA.a, 1.0 - rgbaB.a, f);\r\n // calc color (special formula to emulate blending with bg)\r\n gl_FragColor.rgb = mix(rgbaA.rgb * rgbaA.a, rgbaB.rgb * rgbaB.a, f) / gl_FragColor.a;\r\n #else\r\n if(!horzSpan) {\r\n posM.x += offset;\r\n } else {\r\n posM.y += offset;\r\n }\r\n gl_FragColor = FxaaTexTopAlpha(srcTex, posM);\r\n #endif\r\n return;\r\n}\r\n",transparent:!1,depthTest:!1,depthWrite:!1}),t.setValues(e),t}return l(o,[{key:"copy",value:function(e){Ye(d(o.prototype),"copy",this).call(this,e),this.depth=e.depth}},{key:"setValues",value:function(e){if(void 0!==e){Ye(d(o.prototype),"setValues",this).call(this,e);var t={};this.bgTransparent&&(t.BG_TRANSPARENT=1),this.defines=t}}}]),o}(i.FIo);Yc.prototype.bgTransparent=!1;var Xc=[new i.Pa4(.295184,.077723,.068429),new i.Pa4(-.271976,-.365221,.838363),new i.Pa4(.547713,.467576,.488515),new i.Pa4(.662808,-.031733,.584758),new i.Pa4(-.025717,.218955,.657094),new i.Pa4(-.310153,-.365223,.370701),new i.Pa4(-.101407,-.006313,.747665),new i.Pa4(-.769138,.360399,.086847),new i.Pa4(-.271988,-.27514,.905353),new i.Pa4(.09674,-.566901,.700151),new i.Pa4(.562872,-.735136,.094647),new i.Pa4(.379877,.359278,.190061),new i.Pa4(.519064,-.023055,.405068),new i.Pa4(-.301036,.114696,.088885),new i.Pa4(-.282922,.598305,.487214),new i.Pa4(-.181859,.25167,.679702),new i.Pa4(-.191463,-.635818,.512919),new i.Pa4(-.293655,.427423,.078921),new i.Pa4(-.267983,.680534,.13288),new i.Pa4(.139611,.319637,.477439),new i.Pa4(-.352086,.31104,.653913),new i.Pa4(.321032,.805279,.487345),new i.Pa4(.073516,.820734,.414183),new i.Pa4(-.155324,.589983,.41146),new i.Pa4(.335976,.170782,.527627),new i.Pa4(.46346,-.355658,.167689),new i.Pa4(.222654,.59655,.769406),new i.Pa4(.922138,-.04207,.147555),new i.Pa4(-.72705,-.329192,.369826),new i.Pa4(-.090731,.53382,.463767),new i.Pa4(-.323457,-.876559,.238524),new i.Pa4(-.663277,-.372384,.342856)],qc=function(e){h(o,e);var t,r,n=(t=o,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function o(){var e;return a(this,o),(e=n.call(this)).setValues({uniforms:{noiseTexture:{type:"t",value:ti.noiseTexture},noiseTexelSize:{type:"v2",value:new i.FM8(1/ti.noiseWidth,1/ti.noiseHeight)},diffuseTexture:{type:"t",value:null},normalTexture:{type:"t",value:null},depthTexture:{type:"t",value:null},srcTexelSize:{type:"v2",value:new i.FM8(1/512,1/512)},camNearFar:{type:"v2",value:new i.FM8(1,10)},projMatrix:{type:"mat4",value:new i.yGw},aspectRatio:{type:"f",value:0},tanHalfFOV:{type:"f",value:0},samplesKernel:{type:"v3v",value:Xc},kernelRadius:{type:"f",value:1},depthThreshold:{type:"f",value:1},factor:{type:"f",value:1}},vertexShader:vr,fragmentShader:"precision highp float;\r\n#define EPSILON 0.0000001\r\n\r\n#define MAX_SAMPLES_COUNT 32\r\nuniform vec3 samplesKernel[MAX_SAMPLES_COUNT];\r\nuniform sampler2D noiseTexture;\r\nuniform vec2 noiseTexelSize;\r\nuniform sampler2D diffuseTexture;\r\nuniform sampler2D depthTexture;\r\nuniform sampler2D normalTexture;\r\nuniform vec2 srcTexelSize;\r\nuniform vec2 camNearFar;\r\nuniform mat4 projMatrix;\r\n\r\nuniform float aspectRatio;\r\nuniform float tanHalfFOV;\r\n\r\nuniform float kernelRadius;\r\nuniform float depthThreshold;\r\nuniform float factor;\r\n\r\nvarying vec2 vUv;\r\n\r\nfloat CalcViewZ(vec2 screenPos)\r\n{\r\n float depth = texture2D(depthTexture, screenPos).x;\r\n // [0, 1]->[-1, 1]\r\n float clipedZ = 2.0 * depth - 1.0;\r\n // see THREE.js camera.makeFrustum for projection details\r\n return (-projMatrix[3][2] / (clipedZ + projMatrix[2][2]));\r\n}\r\n\r\nvec3 ViewPosFromDepth(vec2 screenPos)\r\n{\r\n vec3 viewPos;\r\n viewPos.z = CalcViewZ(screenPos);\r\n //[0, 1]->[-1, 1]\r\n vec2 projPos = 2.0 * screenPos - 1.0;\r\n // reconstruct viewposition in right-handed sc with z to viewer\r\n viewPos.xy = vec2(\r\n projPos.x * aspectRatio * tanHalfFOV * abs(viewPos.z),\r\n projPos.y * tanHalfFOV * abs(viewPos.z)\r\n );\r\n return viewPos;\r\n}\r\n\r\nvoid main() {\r\n vec3 viewPos = ViewPosFromDepth(vUv);\r\n // remap coordinates to prevent noise exture rescale\r\n vec2 vUvNoise = vUv / srcTexelSize * noiseTexelSize;\r\n vec4 normalData = texture2D(normalTexture, vUv);\r\n // return for background fragments (their normals are zero vectors)\r\n if (length(normalData.rgb) < EPSILON) {\r\n // 0.0 in alpha component means that it is background fragment\r\n gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0);\r\n return;\r\n }\r\n //[0, 1] -> [-1, 1]\r\n vec3 normal = (normalData.rgb * 2.0 - 1.0);\r\n // normalData.a store 1.0 if normal was build for frontfaced surface\r\n // and 0.0 in other case\r\n if (normalData.a < EPSILON) {\r\n normal *= -1.0;\r\n }\r\n // get random vector for sampling sphere rotation\r\n vec3 randN = texture2D(noiseTexture, vUvNoise).rgb * 2.0 - 1.0;\r\n randN = normalize(randN);\r\n // build TBN (randomly rotated around normal)\r\n vec3 tangent = normalize(randN - normal * dot(randN, normal));\r\n vec3 bitangent = cross(tangent, normal);\r\n mat3 TBN = mat3(tangent, bitangent, normal);\r\n // calc AO value\r\n float AO = 0.0;\r\n for (int i = 0 ; i < MAX_SAMPLES_COUNT ; i++) {\r\n // rotate sampling kernel around normal\r\n vec3 reflectedSample = TBN * samplesKernel[i];\r\n // get sample\r\n vec3 samplePos = viewPos + reflectedSample * kernelRadius;\r\n\r\n // project sample to screen to get sample's screen pos\r\n vec4 SampleScrPos = vec4(samplePos, 1.0);\r\n // eye -> clip\r\n SampleScrPos = projMatrix * SampleScrPos;\r\n // normalize\r\n SampleScrPos.xy /= SampleScrPos.w;\r\n //[-1, 1] -> [0, 1]\r\n SampleScrPos.xy = (SampleScrPos.xy + vec2(1.0)) * 0.5;\r\n\r\n // get view z for sample projected to the objct surface\r\n float sampleDepth = CalcViewZ(SampleScrPos.xy);\r\n // calc occlusion made by object surface at the sample\r\n AO += step(samplePos.z, sampleDepth);\r\n }\r\n // calc result AO-map color\r\n AO = 1.0 - max(0.0, AO / float(MAX_SAMPLES_COUNT) * factor);\r\n // write value to AO-map\r\n gl_FragColor = vec4(AO, AO, AO, 1.0);\r\n}\r\n",transparent:!1,depthTest:!1,depthWrite:!1}),e}return l(o)}(i.FIo);var $c=[-2,-1,0,1,2],Zc=function(e){h(o,e);var t,r,n=(t=o,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function o(){var e;return a(this,o),(e=n.call(this)).setValues({uniforms:{depthTexture:{type:"t",value:null},srcTexelSize:{type:"v2",value:new i.FM8(1/512,1/512)},aoMap:{type:"t",value:null},samplesOffsets:{type:"fv1",value:$c}},vertexShader:vr,fragmentShader:"precision highp float;\r\n#define EPSILON 0.0000001\r\n\r\n#define MAX_SAMPLES_COUNT 5\r\nuniform float samplesOffsets[MAX_SAMPLES_COUNT];\r\nuniform sampler2D aoMap;\r\nuniform sampler2D depthTexture;\r\nuniform vec2 srcTexelSize;\r\n\r\nvarying vec2 vUv;\r\n\r\nvoid main() {\r\n float x = vUv.x;\r\n float y = vUv.y;\r\n vec4 res = vec4(0.0);\r\n res.a = texture2D(aoMap, vec2(x, y )).a;\r\n // return for background fragments (0.0 in alpha component means that it is background fragment)\r\n if (res.a < EPSILON) {\r\n gl_FragColor = res;\r\n return;\r\n }\r\n\r\n float pixelDepth = texture2D(depthTexture, vec2(x, y)).x;\r\n float weightSum = 0.0;\r\n for (int i = 0; i < MAX_SAMPLES_COUNT; ++i) {\r\n if (texture2D(aoMap, vec2(x + samplesOffsets[i] * srcTexelSize.x, y )).a < EPSILON) {\r\n continue;\r\n }\r\n vec2 samplePos = vec2(x + samplesOffsets[i] * srcTexelSize.x, y);\r\n float depth = texture2D(depthTexture, samplePos).x;\r\n float weight = (1.0 / (0.0001 + abs(depth - pixelDepth)));\r\n res.rgb += texture2D(aoMap, vec2(x + samplesOffsets[i] * srcTexelSize.x, y )).rgb * weight;\r\n weightSum += weight;\r\n }\r\n res.rgb = res.rgb / weightSum;\r\n gl_FragColor = res;\r\n}\r\n",transparent:!1,depthTest:!1,depthWrite:!1}),e}return l(o)}(i.FIo);var Kc=[-2,-1,0,1,2],Qc=function(e){h(o,e);var t,r,n=(t=o,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function o(e){var t;return a(this,o),(t=n.call(this,e)).setValues({uniforms:{diffuseTexture:{type:"t",value:null},depthTexture:{type:"t",value:null},srcTexelSize:{type:"v2",value:new i.FM8(1/512,1/512)},aoMap:{type:"t",value:null},samplesOffsets:{type:"fv1",value:Kc},projMatrix:{type:"mat4",value:new i.yGw},aspectRatio:{type:"f",value:0},tanHalfFOV:{type:"f",value:0},fogNearFar:{type:"v2",value:new i.FM8(100,100)},fogColor:{type:"v4",value:new i.Ltg(0,.5,0,1)}},vertexShader:vr,fragmentShader:"precision highp float;\r\n#define EPSILON 0.0000001\r\n\r\n#define MAX_SAMPLES_COUNT 5\r\nuniform float samplesOffsets[MAX_SAMPLES_COUNT];\r\nuniform sampler2D diffuseTexture;\r\nuniform sampler2D aoMap;\r\nuniform sampler2D depthTexture;\r\nuniform vec2 srcTexelSize;\r\n\r\nuniform mat4 projMatrix;\r\nuniform float aspectRatio;\r\nuniform float tanHalfFOV;\r\n\r\n#ifdef USE_FOG\r\n uniform vec2 fogNearFar;\r\n uniform vec4 fogColor;\r\n#endif\r\nvarying vec2 vUv;\r\n\r\nfloat CalcViewZ(vec2 screenPos)\r\n{\r\n float depth = texture2D(depthTexture, screenPos).x;\r\n // [0, 1]->[-1, 1]\r\n float clipedZ = 2.0 * depth - 1.0;\r\n // see THREE.js camera.makeFrustum for projection details\r\n return (-projMatrix[3][2] / (clipedZ + projMatrix[2][2]));\r\n}\r\n\r\nvec3 ViewPosFromDepth(vec2 screenPos)\r\n{\r\n vec3 viewPos;\r\n viewPos.z = CalcViewZ(screenPos);\r\n //[0, 1]->[-1, 1]\r\n vec2 projPos = 2.0 * screenPos - 1.0;\r\n // reconstruct viewposition in right-handed sc with z to viewer\r\n viewPos.xy = vec2(\r\n projPos.x * aspectRatio * tanHalfFOV * abs(viewPos.z),\r\n projPos.y * tanHalfFOV * abs(viewPos.z)\r\n );\r\n return viewPos;\r\n}\r\n\r\nvoid main() {\r\n vec3 viewPos = ViewPosFromDepth(vUv);\r\n float x = vUv.x;\r\n float y = vUv.y;\r\n vec4 color = texture2D(diffuseTexture, vec2(x, y));\r\n vec4 res = vec4(0.0);\r\n res.a = texture2D(aoMap, vec2(x, y )).a;\r\n // return for background fragments (0.0 in alpha component means that it is background fragment)\r\n if (res.a < EPSILON) {\r\n gl_FragColor = color;\r\n return;\r\n }\r\n\r\n float pixelDepth = texture2D(depthTexture, vec2(x, y)).x;\r\n float weightSum = 0.0;\r\n for (int i = 0; i < MAX_SAMPLES_COUNT; ++i) {\r\n if (texture2D(aoMap, vec2(x, y + samplesOffsets[i] * srcTexelSize.y)).a < EPSILON) {\r\n continue;\r\n }\r\n vec2 samplePos = vec2(x, y + samplesOffsets[i] * srcTexelSize.y);\r\n float depth = texture2D(depthTexture, samplePos).x;\r\n float weight = (1.0 / (0.0001 + abs(depth - pixelDepth)));\r\n res.rgb += texture2D(aoMap, vec2(x, y + samplesOffsets[i] * srcTexelSize.y)).rgb * weight;\r\n weightSum += weight;\r\n }\r\n res.rgb /= weightSum;\r\n\r\n #if defined(USE_FOG) && !defined(FOG_TRANSPARENT)\r\n // Add fog to the result value\r\n // Proper way to get an image with fog and ao requires formula:\r\n // gl_FragColor = fragColor*AO*(1-fogFactor) + fogColor*fogFactor\r\n // But we have already fogged molecule to add AO too. Let's split the straight formula into our real steps!\r\n // We have: AO, fogFactor, fogColor,\r\n // color = fragColor*(1-fogFactor) + fogColor*fogFactor (it comes from diffuseTexture,\r\n // where molecule has been already drawn with fog)\r\n // Transform:\r\n // fragColor*AO*(1-fogFactor) + fogColor*fogFactor =\r\n // = [fragColor*(1-fogFactor) = color - fogColor*fogFactor] =\r\n // = (color - fogColor*fogFactor)*AO + fogColor*fogFactor =\r\n // = color*AO + fogColor*fogFactor*(1 - AO)\r\n // Result: gl_FragColor = color*AO + fogColor*fogFactor*(1 - AO)\r\n float fogFactor = smoothstep(fogNearFar.x, fogNearFar.y, - viewPos.z) * fogColor.a;\r\n gl_FragColor.rgb = color.rgb * res.rgb + fogColor.rgb * fogFactor *(vec3(1.0, 1.0, 1.0) - res.rgb);\r\n #else\r\n gl_FragColor.rgb = color.rgb * res.rgb;\r\n #endif\r\n gl_FragColor.a = color.a;\r\n}\r\n",transparent:!1,depthTest:!1,depthWrite:!1}),t.setValues(e),t}return l(o,[{key:"setValues",value:function(e){if(void 0!==e){Ye(d(o.prototype),"setValues",this).call(this,e);var t={};this.useFog&&(t.USE_FOG=1),this.fogTransparent&&(t.FOG_TRANSPARENT=1),this.defines=t}}}]),o}(i.FIo);Qc.prototype.useFog=!0,Qc.prototype.fogTransparent=!1;var Jc=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(){var e;a(this,i),e=n.call(this);var t={uniforms:{srcL:{type:"t",value:null},srcR:{type:"t",value:null}},vertexShader:vr,fragmentShader:"precision highp float;\r\n\r\nuniform sampler2D srcL;\r\nuniform sampler2D srcR;\r\nvarying vec2 vUv;\r\n\r\nvoid main() {\r\n vec4 l = texture2D(srcL, vUv);\r\n vec4 r = texture2D(srcR, vUv);\r\n gl_FragColor = vec4(l.r, r.g, r.b, 1.0);\r\n}\r\n",transparent:!1,depthTest:!1,depthWrite:!1};return e.setValues(t),e}return l(i)}(i.FIo),eu=function(){function e(){a(this,e),this.position=new i.Pa4(0,0,0),this.scale=1,this.orientation=new i._fP(0,0,0,1)}return l(e,[{key:"set",value:function(e,t,r){this.position=e,this.scale=t,this.orientation=r}}]),e}(),tu=function(){function e(){a(this,e)}return l(e,[{key:"setup",value:function(e,t){this._startTime=void 0,this._endTime=void 0,this._isPaused=!1,this._srcView=e,this._dstView=t,this._isMoving=!1}},{key:"isMoving",value:function(){return this._isMoving}},{key:"wasStarted",value:function(){return void 0!==this._startTime&&void 0!==this._endTime}},{key:"start",value:function(){this._startTime=Date.now();var e=J.now.interpolateViews?1500:0;this._endTime=this._startTime+e,this._isMoving=!0}},{key:"getCurrentView",value:function(){if(void 0===this._srcView||void 0===this._dstView||!this._isMoving||!this.wasStarted())return{success:!1};var e=this.createView(),t=Date.now();if(t>this._endTime)return e=this._dstView,this.reset(),{success:!0,view:e};var r=(t-this._startTime)/(this._endTime-this._startTime);return e.position.copy(this._srcView.position),e.position.lerp(this._dstView.position,r),e.scale=(1-r)*this._srcView.scale+r*this._dstView.scale,e.orientation.copy(this._srcView.orientation),e.orientation.slerp(this._dstView.orientation,r),{success:!0,view:e}}},{key:"reset",value:function(){this._startTime=this._endTime=0,this._isMoving=!1}},{key:"pause",value:function(){this._isPaused||(this.setup(this.getCurrentView().view,this._dstView),this._isPaused=!0)}},{key:"resume",value:function(){this._isPaused=!1}},{key:"createView",value:function(){return new eu}}]),e}();function ru(e,t){this.context=e,this._opts=(0,n.merge)({path:"/"},t)}Nr(ru.prototype),ru.prototype.removeCookie=function(e){var t=this._toCount(e),r=this._getSimpleCookie(t);if(r){this._removeSimpleCookie(t),r=parseInt(r,10);for(var n=0;n=0&&(e=e.substr(0,t)),e}function fu(e,t,r){void 0!==r?e.debug("".concat(t,"... ").concat(Math.floor(100*r),"%")):e.debug("".concat(t,"..."))}function du(){return J.now.fogColorEnable?J.now.fogColor:J.now.bg.color}function pu(e,t){for(var r=e;r.firstChild;)r.removeChild(r.firstChild);r.appendChild(t)}function mu(e){return e.getExtension("EXT_frag_depth")}function vu(e){return e.getExtension("WEBGL_depth_texture")&&e.getExtension("WEBGL_draw_buffers")}var yu=/^(?:(pdb|cif|mmtf|ccp4|dsn6):\s*)?(\d[a-z\d]{3})$/i,_u=/^(?:pc|pubchem):\s*([a-z]+)$/i,gu=/^([a-z][a-z\d\-+.]*):/i;function xu(e,t){return e.mask&1<1))throw this._showMessage("Viewer initialization failed."),e;this._showMessage(e.message)}return!1}var o=this._opts&&this._opts.load;if(o){var a=this._opts&&this._opts.type;this.load(o,{fileType:a,keepRepsInfo:!0})}return!0}},{key:"term",value:function(){this._showMessage("Viewer has been terminated."),this._loading.forEach((function(e){e.cancel()})),this._loading.length=0,this.halt(),this._gfx=null}},{key:"_showMessage",value:function(e){var t=document.createElement("div");t.setAttribute("class","miew-message"),t.appendChild(document.createElement("p")).appendChild(document.createTextNode(e)),pu(this._container,t)}},{key:"_showCanvas",value:function(){pu(this._container,this._gfx.renderer.domElement)}},{key:"_requestAnimationFrame",value:function(e){var t=this._gfx.renderer.xr;t&&t.enabled?this._gfx.renderer.setAnimationLoop(e):requestAnimationFrame(e)}},{key:"_initGfx",value:function(){var e={width:this._container.clientWidth,height:this._container.clientHeight},t={preserveDrawingBuffer:!0,alpha:!0,premultipliedAlpha:!1};J.now.antialias&&(t.antialias=!0),e.renderer2d=new Tc,e.renderer=new i.b5g(t),e.renderer.shadowMap.enabled=J.now.shadow.on,e.renderer.shadowMap.autoUpdate=!1,e.renderer.shadowMap.type=i._iA,Xn.init(e.renderer),mu(e.renderer.getContext())||J.set("zSprites",!1),vu(e.renderer.getContext())||J.set("ao",!1),e.renderer.autoClear=!1,e.renderer.setPixelRatio(window.devicePixelRatio),e.renderer.setSize(e.width,e.height),e.renderer.setClearColor(J.now.bg.color,Number(!J.now.bg.transparent)),e.renderer.clearColor(),e.renderer2d.setSize(e.width,e.height),e.camera=new i.cPb(J.now.camFov,e.width/e.height,J.now.camNear,J.now.camFar),e.camera.setMinimalFov(J.now.camFov),e.camera.position.z=J.now.camDistance,e.camera.updateProjectionMatrix(),e.camera.layers.set(Ar.LAYERS.DEFAULT),e.camera.layers.enable(Ar.LAYERS.VOLUME),e.camera.layers.enable(Ar.LAYERS.VOLUME_BFPLANE),e.stereoCam=new i.u37,e.scene=new i.xsS;var r=du();e.scene.fog=new i.ybr(r,J.now.camNear,J.now.camFar),e.root=new Ar.RCGroup,e.scene.add(e.root),e.pivot=new Ar.RCGroup,e.root.add(e.pivot),e.selectionScene=new i.xsS,e.selectionRoot=new i.ZAu,e.selectionRoot.matrixAutoUpdate=!1,e.selectionScene.add(e.selectionRoot),e.selectionPivot=new i.ZAu,e.selectionPivot.matrixAutoUpdate=!1,e.selectionRoot.add(e.selectionPivot);var n=new i.Ox3(16777215,.45);n.position.set(0,.414,1),n.layers.enable(Ar.LAYERS.TRANSPARENT),n.castShadow=!0,n.shadow.bias=.09,n.shadow.radius=J.now.shadow.radius,n.shadow.camera.layers.set(Ar.LAYERS.SHADOWMAP);var o=e.renderer.getPixelRatio(),a=Math.max(e.width,e.height)*o;n.shadow.mapSize.width=a,n.shadow.mapSize.height=a,n.target.position.set(0,0,0),e.scene.add(n),e.scene.add(n.target);var s=new i.Mig(6710886);s.layers.enable(Ar.LAYERS.TRANSPARENT),e.scene.add(s),e.axes=new Dc(e.root,e.camera);var l=e.width*o,c=e.height*o;e.offscreenBuf=new i.dd2(l,c,{minFilter:i.wem,magFilter:i.TyD,format:i.wk1,depthBuffer:!0}),e.renderer.getContext().getExtension("WEBGL_depth_texture")&&(e.offscreenBuf.depthTexture=new i.$YQ,e.offscreenBuf.depthTexture.type=i.LsT),e.offscreenBuf2=new i.dd2(l,c,{minFilter:i.wem,magFilter:i.wem,format:i.wk1,depthBuffer:!1}),e.offscreenBuf3=new i.dd2(l,c,{minFilter:i.wem,magFilter:i.wem,format:i.wk1,depthBuffer:!1}),e.offscreenBuf4=new i.dd2(l,c,{minFilter:i.wem,magFilter:i.wem,format:i.wk1,depthBuffer:!1}),e.volBFTex=e.offscreenBuf3,e.volFFTex=e.offscreenBuf4,e.volWFFTex=e.offscreenBuf,e.renderer.getContext().getExtension("OES_texture_float")?(e.offscreenBuf5=new i.dd2(l,c,{minFilter:i.wem,magFilter:i.wem,format:i.wk1,type:i.VzW,depthBuffer:!1}),e.offscreenBuf6=new i.dd2(l,c,{minFilter:i.wem,magFilter:i.wem,format:i.wk1,type:i.VzW,depthBuffer:!1}),e.offscreenBuf7=new i.dd2(l,c,{minFilter:i.wem,magFilter:i.wem,format:i.wk1,type:i.VzW,depthBuffer:!0}),e.volBFTex=e.offscreenBuf5,e.volFFTex=e.offscreenBuf6,e.volWFFTex=e.offscreenBuf7):this.logger.warn("Device doesn't support OES_texture_float extension"),e.stereoBufL=new i.dd2(l,c,{minFilter:i.wem,magFilter:i.wem,format:i.wk1,depthBuffer:!1}),e.stereoBufR=new i.dd2(l,c,{minFilter:i.wem,magFilter:i.wem,format:i.wk1,depthBuffer:!1}),this._gfx=e,this._showCanvas(),this._embedWebXR("WEBVR"===J.now.stereo),this._container.appendChild(e.renderer2d.getElement());var u=new k;u.domElement.style.position="absolute",u.domElement.style.right="0",u.domElement.style.bottom="0",this._container.appendChild(u.domElement),this._fps=u,this._fps.show(J.now.fps)}},{key:"_initListeners",value:function(){var e=this;window.addEventListener("resize",(function(){e._onResize()}))}},{key:"_makeUniqueVisualName",value:function(e){if(!e)return Math.random().toString();for(var t=e,r=1;this._visuals.hasOwnProperty(t);)t="".concat(e," (").concat(r.toString(),")"),r++;return t}},{key:"_addVisual",value:function(e){if(!e)return null;var t=this._makeUniqueVisualName(e.name);return e.name=t,this._visuals[t]=e,this._gfx.pivot.add(e),e.getSelectionGeo&&this._gfx.selectionPivot.add(e.getSelectionGeo()),t}},{key:"_removeVisual",value:function(e){var t="",r=null;e instanceof kr?(t=e.name,r=e):"string"==typeof e&&(t=e,r=this._visuals[t]),r&&this._visuals.hasOwnProperty(t)&&this._visuals[t]===r&&(t===this._curVisualName&&(this._curVisualName=void 0),delete this._visuals[t],r.release(),this._needRender=!0)}},{key:"_forEachVisual",value:function(e){for(var t in this._visuals)this._visuals.hasOwnProperty(t)&&e(this._visuals[t])}},{key:"_releaseAllVisuals",value:function(){if(this._gfx&&this._gfx.pivot){for(var e in this._visuals)this._visuals.hasOwnProperty(e)&&this._visuals[e].release();this._visuals={}}}},{key:"_forEachComplexVisual",value:function(e){if(this._gfx&&this._gfx.pivot)for(var t in this._visuals)this._visuals.hasOwnProperty(t)&&this._visuals[t]instanceof Fa&&e(this._visuals[t])}},{key:"_getComplexVisual",value:function(e){e=e||this._curVisualName;var t=null,r=null;return this._forEachComplexVisual((function(n){t=n,n.name===e&&(r=n)})),r||t}},{key:"_getVolumeVisual",value:function(){var e=null;return this._forEachVisual((function(t){t instanceof Za&&(e=t)})),e}},{key:"_getVisualForComplex",value:function(e){if(!e)return null;var t=null;return this._forEachComplexVisual((function(r){r.getComplex()===e&&(t=r)})),t}},{key:"getVisuals",value:function(){return Object.keys(this._visuals)}},{key:"getComplexVisualsCount",value:function(){var e=0;return this._forEachComplexVisual((function(){return e++})),e}},{key:"getCurrentVisual",value:function(){return this._curVisualName}},{key:"setCurrentVisual",value:function(e){this._visuals[e]&&(this._curVisualName=e)}},{key:"run",value:function(){var e=this;if(!this._running){if(this._running=!0,this._halting)return void(this._halting=!1);this._objectControls.enable(!0),this._interpolator.resume(),this._requestAnimationFrame((function(){return e._onTick()}))}}},{key:"halt",value:function(){this._running&&(this._discardComponentEdit(),this._discardFragmentEdit(),this._objectControls.enable(!1),this._interpolator.pause(),this._halting=!0)}},{key:"enableHotKeys",value:function(e){this._hotKeysEnabled=e,this._objectControls.enableHotkeys(e)}},{key:"_onResize",value:function(){this._needRender=!0;var e=this._gfx;e.width=this._container.clientWidth,e.height=this._container.clientHeight,e.camera.aspect=e.width/e.height,e.camera.setMinimalFov(J.now.camFov),e.camera.updateProjectionMatrix(),e.renderer.setSize(e.width,e.height),e.renderer2d.setSize(e.width,e.height),this.dispatchEvent({type:"resize"})}},{key:"_resizeOffscreenBuffers",value:function(e,t,r){var n=this._gfx,i="NONE"===(r=r||"NONE")||"ANAGLYPH"===r,o=i?1:.5;n.offscreenBuf.setSize(o*e,t),n.offscreenBuf2.setSize(o*e,t),n.offscreenBuf3.setSize(o*e,t),n.offscreenBuf4.setSize(o*e,t),n.offscreenBuf5&&n.offscreenBuf5.setSize(o*e,t),n.offscreenBuf6&&n.offscreenBuf6.setSize(o*e,t),n.offscreenBuf7&&n.offscreenBuf7.setSize(o*e,t),i&&(n.stereoBufL.setSize(e,t),n.stereoBufR.setSize(e,t))}},{key:"_onTick",value:function(){var e=this;if(this._halting)return this._running=!1,void(this._halting=!1);this._fps.update(),this._requestAnimationFrame((function(){return e._onTick()})),this._onUpdate(),this._needRender&&(this._onRender(),this._needRender=!J.now.suspendRender||"WEBVR"===J.now.stereo)}},{key:"_getBSphereRadius",value:function(){var e=0;return this._forEachVisual((function(t){e=Math.max(e,t.getBoundaries().boundingSphere.radius)})),e*this._objectControls.getScale()}},{key:"getOBB",value:function(e,t){var r=this;this._bBox.makeEmpty(),this._forEachVisual((function(t){r._bSphereForOneVisual.copy(t.getBoundaries().boundingSphere),r._bSphereForOneVisual.applyMatrix4(t.matrixWorld).applyMatrix4(e),r._bSphereForOneVisual.getBoundingBox(r._bBoxForOneVisual),r._bBox.union(r._bBoxForOneVisual)})),this._bBox.getCenter(t.center),this._invMatrix.copy(e).invert(),t.center.applyMatrix4(this._invMatrix);var n=this._bBox.min,i=this._bBox.max;this._points[0].set(n.x,n.y,n.z),this._points[1].set(i.x,n.y,n.z),this._points[2].set(n.x,i.y,n.z),this._points[3].set(n.x,n.y,i.z);for(var o=0,a=this._points.length;o0)return!0;return!1}},{key:"_renderSelection",value:function(e,t,r){var n=new Wc,i=this._gfx;i.renderer.setClearColor("black",0),i.renderer.setRenderTarget(t),i.renderer.clear(!0,!1,!1),this._hasSelectionToRender()?(i.selectionRoot.matrix=i.root.matrix,i.selectionPivot.matrix=i.pivot.matrix,i.renderer.render(i.selectionScene,e)):i.renderer.renderDummyQuad(),i.renderer.setRenderTarget(r),i.renderer.renderScreenQuadFromTex(t.texture,.6),n.uniforms.srcTex.value=t.texture,n.uniforms.srcTexSize.value.set(t.width,t.height),i.renderer.renderScreenQuad(n)}},{key:"_checkVolumeRenderingSupport",value:function(e){if(!e)return!1;var t=this._gfx,r=t.renderer.getRenderTarget();t.renderer.setRenderTarget(e);var n=t.renderer.getContext(),i=n.checkFramebufferStatus(n.FRAMEBUFFER);return t.renderer.setRenderTarget(r),i===n.FRAMEBUFFER_COMPLETE||(this.logger.warn("Device doesn't support electron density rendering"),!1)}},{key:"_renderVolume",value:function(e,t,r,n,o,a){var s,l=new Ya.BackFacePosMaterial,c=new Ya.FrontFacePosMaterial,u=(new i.yGw).makeTranslation(.5,.5,.5),h=new i.yGw,f=this._gfx;if(void 0===s&&(s=this._checkVolumeRenderingSupport(n)),s){var d=e.getMesh();d.rebuild(f.camera),f.renderer.setClearColor("black",0),f.renderer.setRenderTarget(n),f.renderer.clear(),f.renderer.setRenderTarget(o),f.renderer.clear(),f.renderer.setRenderTarget(a),f.renderer.clear(),f.renderer.setRenderTarget(n),t.layers.set(Ar.LAYERS.VOLUME_BFPLANE),f.renderer.render(f.scene,t),t.layers.set(Ar.LAYERS.VOLUME),f.scene.overrideMaterial=l,f.renderer.render(f.scene,t),f.renderer.setRenderTarget(o),t.layers.set(Ar.LAYERS.VOLUME),f.scene.overrideMaterial=c,f.renderer.render(f.scene,t),f.scene.overrideMaterial=null,t.layers.set(Ar.LAYERS.DEFAULT),h.copy(d.matrixWorld).invert(),li.prototype.uberOptions.world2colorMatrix.multiplyMatrices(u,h),t.layers.set(Ar.LAYERS.COLOR_FROM_POSITION),f.renderer.setRenderTarget(a),f.renderer.render(f.scene,t);var p=d.material;p.uniforms._BFRight.value=n.texture,p.uniforms._FFRight.value=o.texture,p.uniforms._WFFRight.value=a.texture,t.layers.set(Ar.LAYERS.VOLUME),f.renderer.setRenderTarget(r),f.renderer.render(f.scene,t),t.layers.set(Ar.LAYERS.DEFAULT)}}},{key:"_renderWithPrepassTransparency",value:function(e,t){var r=this._gfx;r.renderer.setRenderTarget(t),e.layers.set(Ar.LAYERS.DEFAULT),r.renderer.render(r.scene,e),e.layers.set(Ar.LAYERS.PREPASS_TRANSPARENT),r.renderer.getContext().colorMask(!1,!1,!1,!1),r.renderer.render(r.scene,e),r.renderer.getContext().colorMask(!0,!0,!0,!0),e.layers.set(Ar.LAYERS.TRANSPARENT),r.renderer.render(r.scene,e),e.layers.set(Ar.LAYERS.DEFAULT)}},{key:"_performFXAA",value:function(e,t){var r=new Yc;if(void 0!==e&&void 0!==t){var n=this._gfx;n.renderer.setClearColor(J.now.bg.color,Number(!J.now.bg.transparent)),n.renderer.setRenderTarget(t),n.renderer.clear(),r.uniforms.srcTex.value=e.texture,r.uniforms.srcTexelSize.value.set(1/e.width,1/e.height),r.uniforms.bgColor.value.set(J.now.bg.color),r.bgTransparent!==J.now.bg.transparent&&(r.setValues({bgTransparent:J.now.bg.transparent}),r.needsUpdate=!0),n.renderer.renderScreenQuad(r)}}},{key:"_performAO",value:function(e,t,r,n,o,a){var s=new qc,l=new Zc,c=new Qc,u=new i.Pa4;if(e&&t&&r&&n&&o&&a){var h=this._gfx,f=Math.tan(.5*i.M8C.DEG2RAD*h.camera.fov);s.uniforms.diffuseTexture.value=e.texture,s.uniforms.depthTexture.value=r,s.uniforms.normalTexture.value=t.texture,s.uniforms.srcTexelSize.value.set(1/e.width,1/e.height),s.uniforms.camNearFar.value.set(h.camera.near,h.camera.far),s.uniforms.projMatrix.value=h.camera.projectionMatrix,s.uniforms.aspectRatio.value=h.camera.aspect,s.uniforms.tanHalfFOV.value=f,h.root.matrix.extractScale(u),s.uniforms.kernelRadius.value=J.now.debug.ssaoKernelRadius*u.x,s.uniforms.depthThreshold.value=2*this._getBSphereRadius(),s.uniforms.factor.value=J.now.debug.ssaoFactor,h.renderer.setRenderTarget(a),h.renderer.renderScreenQuad(s),l.uniforms.aoMap.value=a.texture,l.uniforms.srcTexelSize.value.set(1/a.width,1/a.height),l.uniforms.depthTexture.value=r,h.renderer.setRenderTarget(o),h.renderer.renderScreenQuad(l),c.uniforms.aoMap.value=o.texture,c.uniforms.diffuseTexture.value=e.texture,c.uniforms.srcTexelSize.value.set(1/o.width,1/o.height),c.uniforms.depthTexture.value=r,c.uniforms.projMatrix.value=h.camera.projectionMatrix,c.uniforms.aspectRatio.value=h.camera.aspect,c.uniforms.tanHalfFOV.value=f;var d=h.scene.fog;d&&(c.uniforms.fogNearFar.value.set(d.near,d.far),c.uniforms.fogColor.value.set(d.color.r,d.color.g,d.color.b,J.now.fogAlpha)),c.useFog===J.now.fog&&c.fogTransparent===J.now.bg.transparent||(c.setValues({useFog:J.now.fog,fogTransparent:J.now.bg.transparent}),c.needsUpdate=!0),h.renderer.setRenderTarget(n),h.renderer.renderScreenQuad(c)}}},{key:"reset",value:function(){this._picker&&this._picker.reset(),this._lastPick=null,this._releaseAllVisuals(),this._setEditMode(0),this._resetObjects(),this._gfx&&(Ar.clearTree(this._gfx.pivot),this._gfx.renderer2d.reset()),this.setNeedRender()}},{key:"_resetScene",value:function(){this._objectControls.reset(),this._objectControls.allowTranslation(!0),this._objectControls.allowAltObjFreeRotation(!0),this.resetReps(),this.resetPivot(),this.rebuildAll()}},{key:"resetView",value:function(){this._picker&&this._picker.reset(),this._setEditMode(0),this._resetScene(),this._forEachComplexVisual((function(e){e.updateSelectionMask({}),e.rebuildSelectionGeometry()}))}},{key:"_export",value:function(e){var t=(0,n.head)(kc.exporters.find({format:e}));if(!t)return this.logger.error("Could not find suitable exporter for this source"),Promise.reject(new Error("Could not find suitable exporter for this source"));if(this.dispatchEvent({type:"exporting"}),this._visuals[this._curVisualName]instanceof Fa){var r=null;return t.SourceClass===Fa?r=this._visuals[this._curVisualName]:t.SourceClass===cr&&(r=this._visuals[this._curVisualName]._complex),new t(r,{miewVersion:s.VERSION}).export().then((function(e){return e}))}return this._visuals[this._curVisualName]instanceof Za?Promise.reject(new Error("Sorry, exporter for volume data not implemented yet")):Promise.reject(new Error("Unexpected format of data"))}},{key:"load",value:function(e,t){var r=this;t=(0,n.merge)({},t,{context:this}),this.settings.now.use.multiFile||(this._loading.length&&(this._loading.forEach((function(e){e.cancel()})),this._loading.length=0),t.animation||this.reset(!0)),this._interpolator.reset(),this.dispatchEvent({type:"loading",options:t,source:e});var i=new Z;this._loading.push(i),i.addEventListener("notification",(function(e){r.dispatchEvent(e.slaveEvent)})),this._spinner.spin(this._container);var o=function(e){var t=r._loading.indexOf(i);return-1!==t&&r._loading.splice(t,1),r._spinner.stop(),r._refreshTitle(),i.notify({type:"loadingDone",anything:e}),e};return function(e,t,r){return new Promise((function(i){if(r.shouldCancel())throw new Error("Operation cancelled");r.notify({type:"fetching"}),e=function(e,t){if(!(0,n.isString)(e))return e;var r=yu.exec(e);if(r){var i=v(r,3),o=i[1],a=void 0===o?"pdb":o,s=i[2];switch(a=a.toLowerCase(),s=s.toUpperCase(),a){case"pdb":e="https://files.rcsb.org/download/".concat(s,".pdb");break;case"cif":e="https://files.rcsb.org/download/".concat(s,".cif");break;case"mmtf":e="https://mmtf.rcsb.org/v1.0/full/".concat(s);break;case"ccp4":e="https://www.ebi.ac.uk/pdbe/coordinates/files/".concat(s.toLowerCase(),".ccp4");break;case"dsn6":e="https://edmaps.rcsb.org/maps/".concat(s.toLowerCase(),"_2fofc.dsn6");break;default:throw new Error("Unexpected data format shortcut")}return t.fileType=a,t.fileName="".concat(s,".").concat(a),t.sourceType="url",e}var l=_u.exec(e);if(l){var c=l[1].toLowerCase();return e="https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/name/".concat(c,"/JSON?record_type=3d"),t.fileType="pubchem",t.fileName="".concat(c,".json"),t.sourceType="url",e}return"url"!==t.sourceType&&void 0!==t.sourceType||(t.sourceType="url",gu.test(e)||(e=$.resolveURL(e))),e}(e,t);var o=(0,n.head)(kc.loaders.find({type:t.sourceType,source:e}));if(!o)throw new Error(cu);var a=t.fileName||o.extractName(e);if(a){var s=v($.splitFileName(a),2),l=s[0],c=s[1];(0,n.defaults)(t,{name:l,fileExt:c,fileName:a})}!function(e){var t=e.binary;if(void 0!==e.fileType){var r=(0,n.head)(kc.parsers.find({format:e.fileType}));if(!r)throw new Error("Could not find suitable parser for this format");t=r.binary||!1}if(void 0===t&&void 0!==e.fileExt){var i=(0,n.head)(kc.parsers.find({ext:e.fileExt}));i&&(t=i.binary||!1)}void 0!==e.fileExt&&".man"===e.fileExt.toLowerCase()&&(e.binary=!0,e.animation=!0),void 0!==t&&void 0!==e.binary&&e.binary!==t&&e.context.logger.warn("Overriding incorrect binary mode"),e.binary=t||!1}(t);var u=(0,n.get)(t,"preset.expression");if(!(0,n.isUndefined)(u)&&(u=JSON.parse(u))&&u.settings)for(var h=["singleUnit"],f=0,d=h.length;f0?fu(y.logger,"Fetching",e.loaded/e.total):fu(y.logger,"Fetching")})),console.time("fetch"),i(y.load().then((function(e){return console.timeEnd("fetch"),t.context.logger.info("Fetching finished"),r.notify({type:"fetchingDone",data:e}),e})).catch((function(e){throw console.timeEnd("fetch"),t.context.logger.debug(e.message),e.stack&&t.context.logger.debug(e.stack),t.context.logger.error("Fetching failed"),r.notify({type:"fetchingDone",error:e}),e})))}))}(e,t,i).then((function(e){return function(e,t,r){if(r.shouldCancel())return Promise.reject(new Error("Operation cancelled"));r.notify({type:"parsing"});var i=(0,n.head)(kc.parsers.find({format:t.fileType,ext:t.fileExt,data:e}));if(!i)return Promise.reject(new Error("Could not find suitable parser"));var o=new i(e,t);return o.context=t.context,r.addEventListener("cancel",(function(){return o.abort()})),console.time("parse"),o.parse().then((function(e){return console.timeEnd("parse"),r.notify({type:"parsingDone",data:e}),e})).catch((function(e){throw console.timeEnd("parse"),t.error=e,t.context.logger.debug(e.message),e.stack&&t.context.logger.debug(e.stack),t.context.logger.error("Parsing failed"),r.notify({type:"parsingDone",error:e}),e}))}(e,t,i)})).then((function(e){var n=r._onLoad(e,t);return o(n)})).catch((function(e){throw r.logger.error("Could not load data"),r.logger.debug(e),o(e)}))}},{key:"unload",value:function(e){this._removeVisual(e||this.getCurrentVisual()),this.resetPivot(),J.now.shadow.on&&this._updateShadowCamera()}},{key:"_startAnimation",value:function(e){this._stopAnimation();var t=this,r=this._getComplexVisual();if(null!==r){try{this._frameInfo=new Gc(r.getComplex(),e,{onLoadStatusChanged:function(){t.dispatchEvent({type:"mdPlayerStateChanged",state:{isPlaying:t._isAnimating,isLoading:!t._frameInfo||t._frameInfo.isLoading}})},onError:function(e){t._stopAnimation(),t.logger.error(e)}})}catch(e){return void this.logger.error("Animation file does not fit to current complex!")}this._continueAnimation()}else this.logger.error("Unable to start animation - no molecule is loaded.")}},{key:"_pauseAnimation",value:function(){null!==this._animInterval&&(this._isAnimating=!1,clearInterval(this._animInterval),this._animInterval=null,this._frameInfo&&this.dispatchEvent({type:"mdPlayerStateChanged",state:{isPlaying:this._isAnimating,isLoading:this._frameInfo.isLoading}}))}},{key:"_continueAnimation",value:function(){this._isAnimating=!0;var e=1e3/J.now.maxfps;e=Number.isNaN(e)?0:e;var t=this,r=t._gfx.pivot,n=this._getComplexVisual();n&&(n.resetSelectionMask(),n.rebuildSelectionGeometry(),this._msgAtomInfo.style.opacity=0),this._animInterval=setInterval((function(){if(t.dispatchEvent({type:"mdPlayerStateChanged",state:{isPlaying:t._isAnimating,isLoading:t._frameInfo.isLoading}}),t._frameInfo.frameIsReady){r.updateToFrame(t._frameInfo),t._updateObjsToFrame(t._frameInfo),t._refreshTitle(" Frame ".concat(t._frameInfo._currFrame," of ").concat(t._frameInfo._framesCount," time interval - ").concat(t._frameInfo._timeStep));try{t._frameInfo.nextFrame()}catch(e){return t.logger.error("Error during animation"),void t._stopAnimation()}t._needRender=!0}}),e)}},{key:"_stopAnimation",value:function(){null!==this._animInterval&&(clearInterval(this._animInterval),this._frameInfo.disableEvents(),this._frameInfo=null,this._animInterval=null,this.dispatchEvent({type:"mdPlayerStateChanged",state:null}))}},{key:"_onLoad",value:function(e,t){var r=this._gfx,i=null;if(t.animation)return this._refreshTitle(),this._startAnimation(e),null;if(this._stopAnimation(),t&&t.keepRepsInfo||(this._opts.reps=null,this._opts._objects=null),"Complex"===e.id){var o=e;t.fileName?o.name=o.name||hu(t.fileName).toUpperCase():t.amberFileName?o.name=o.name||hu(t.amberFileName).toUpperCase():o.name="Dynamic ".concat(t.fileType," molecule"),i=this._addVisual(new Fa(o.name,o)),this._curVisualName=i;var a=this.info();if(this.logger.info("Parsed ".concat(t.fileName," (").concat(a.atoms," atoms, ").concat(a.bonds," bonds, ").concat(a.residues," residues, ").concat(a.chains," chains).")),(0,n.isNumber)(this._opts.unit)&&o.setCurrentUnit(this._opts.unit),t.preset);else if(J.now.autoPreset)switch(t.fileType){case"cml":this.resetReps("small");break;case"pdb":case"mmtf":case"cif":!function(e){var t=!1;return e.forEachComponent((function(e){e.forEachResidue((function(e){e._isValid&&(t=!0)}))})),t}(o)?this.resetReps("small"):this.resetReps("macro");break;default:this.resetReps("default")}else this.resetReps("default")}else"Volume"===e.id&&(this.resetEd(),i=this._onLoadEd(e));return r.camera.updateProjectionMatrix(),this._updateFog(),r.root.resetTransform(),this.resetPivot(),this._objectControls.setScale(J.now.radiusToFit/this._getBSphereRadius()),this._resetObjects(),J.now.autoResolution&&this._tweakResolution(),J.now.shadow.on&&this._updateShadowCamera(),this._opts.view&&(this.view(this._opts.view),delete this._opts.view),this._refreshTitle(),i}},{key:"resetEd",value:function(){this._edLoader&&(this._edLoader.abort(),this._edLoader=null),this._removeVisual(this._getVolumeVisual()),this._needRender=!0}},{key:"loadEd",value:function(e){var t=this;this.resetEd();var r=(0,n.head)(kc.loaders.find({source:e}));if(!r)return this.logger.error(cu),Promise.reject(new Error(cu));var i=this._edLoader=new r(e,{binary:!0});return i.context=this,i.load().then((function(e){var r=(0,n.head)(kc.parsers.find({format:"ccp4"}));if(!r)throw new Error("Could not find suitable parser for this source");var i=new r(e);return i.context=t,i.parse().then((function(e){t._onLoadEd(e)}))})).catch((function(e){t.logger.error("Could not load ED data"),t.logger.debug(e)}))}},{key:"_onLoadEd",value:function(e){e.normalize();var t=new Za("volume",e);t.getMesh().layers.set(Ar.LAYERS.VOLUME);var r=this._addVisual(t);return this._needRender=!0,r}},{key:"_needRebuild",value:function(){var e=!1;return this._forEachComplexVisual((function(t){e=e||t.needsRebuild()})),e}},{key:"_rebuildObjects",value:function(){var e,t,r=this,n=this._gfx,i=[];for(e=0;e0?"Bio molecule ".concat(r):"Asymmetric unit","Current unit: ".concat(r," (").concat(i,")")}},{key:"rebuild",value:function(){var e=this;if(this._building)this.logger.warn("Miew.rebuild(): already building!");else{this._building=!0,this.dispatchEvent({type:"rebuilding"}),this._rebuildObjects(),this._gfx.renderer2d.reset();var t=[];this._forEachComplexVisual((function(e){e.needsRebuild()&&t.push(e.rebuild().then((function(){return new Promise((function(t){e.rebuildSelectionGeometry(),t()}))})))}));var r=this;this._spinner.spin(this._container),Promise.all(t).then((function(){r._spinner.stop(),r._needRender=!0,r._refreshTitle(),e.dispatchEvent({type:"buildingDone"}),r._building=!1}))}}},{key:"rebuildAll",value:function(){this._forEachComplexVisual((function(e){e.setNeedsRebuild()}))}},{key:"_refreshTitle",value:function(e){var t;e=void 0===e?"":e;var r=this._getComplexVisual();if(r){t=r.getComplex().name;var n=r.repGet(r.repCurrent());t+=n?" – ".concat(n.mode.name," Mode"):""}else t=Object.keys(this._visuals).length>0?"Unknown":"No Data";t+=e,this.dispatchEvent({type:"titleChanged",data:t})}},{key:"setNeedRender",value:function(){this._needRender=!0}},{key:"_extractRepresentation",value:function(){var e=this,t=[];this._forEachComplexVisual((function(r){if(0!==r.getSelectionCount()){var n=r.buildSelectorFromMask(1<0&&this.logger.report("New representation from selection for complexes: ".concat(t.join(", ")))}},{key:"_setReps",value:function(e){e=e||this._opts&&this._opts.reps||[],this._forEachComplexVisual((function(t){return t.resetReps(e)}))}},{key:"applyPreset",value:function(e){for(var t=J.now.presets,r=[e||J.defaults.preset,J.defaults.preset,Object.keys(t)[0]],n=null,i=0;!n&&i0&&e.push(t)})),1===e.length){var t=e[0].beginFragmentEdit();t&&(this._editors=[t],this.logger.info("FRAGMENT EDIT MODE -- ON (single bond)"),this._setEditMode(2),this._objectControls.allowTranslation(!1),this._objectControls.allowAltObjFreeRotation(t.isFreeRotationAllowed()),this._needRender=!0)}}}},{key:"_applyFragmentEdit",value:function(){if(2===this._editMode){this._objectControls.stop();for(var e=0;e0){if(e){e=null;break}e=r}}if(e)return e}return{objects:[],pivot:new i.Pa4(0,0,0)}}},{key:"resetPivot",value:function(){var e=new i.ZzF,t=new i.Pa4;e.makeEmpty(),this._forEachVisual((function(t){e.union(t.getBoundaries().boundingBox)})),e.getCenter(t),this._objectControls.setPivot(t.negate()),this.dispatchEvent({type:"transform"})}},{key:"setPivotResidue",value:function(e){var t=new i.Pa4,r=this._getVisualForComplex(e.getChain().getComplex());if(r){if(e._controlPoint)t.copy(e._controlPoint);else{for(var n=0,o=0,a=0,s=e._atoms.length,l=0;l0)for(var r=1e6*this._gfxScore/t,n=0;ni?(a=!1,r.preset="empty"):J.now.preset!==J.defaults.preset&&(r.preset=J.now.preset);for(var s=[],l=!0,c=0,u=i;c0&&(t._objects=u),e.view&&(t.view=this.view()),e.settings){var d=this.settings.getDiffs(!1);(0,n.isEmpty)(d)||(t.settings=d)}return t}},{key:"get",value:function(e,t){return J.get(e,t)}},{key:"_clipPlaneUpdateValue",value:function(e){var t=Math.max(this._gfx.camera.position.z-e*J.now.draft.clipPlaneFactor,J.now.camNear),r={clipPlaneValue:t};this._forEachComplexVisual((function(e){e.setUberOptions(r)}));for(var n=0,i=this._objects.length;n1&&void 0!==arguments[1]&&arguments[1],r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0;this._forEachComplexVisual((function(n){return n.setMaterialValues(e,t,r)}));for(var n=0,i=this._objects.length;n1)&&e.logger.warn("fogAlpha must belong range [0,1]"),e._fogAlphaChanged(),e._needRender=!0})),t("autoResolution",(function(t){t.value&&!e._gfxScore&&e.logger.warn("Benchmarks are missed, autoresolution will not work! Autoresolution should be set during miew startup.")})),t("stereo",(function(){e._embedWebXR("WEBVR"===J.now.stereo),e._needRender=!0})),t(["transparency","palette"],(function(){e.rebuildAll()})),t("resolution",(function(){e.rebuildAll();var t=e._getVolumeVisual();t&&(t.getMesh().material.updateDefines(),e._needRender=!0)})),t(["axes","fxaa","ao","outline.on","outline.color","outline.threshold","outline.thickness"],(function(){e._needRender=!0}))}},{key:"set",value:function(e,t){J.set(e,t)}},{key:"select",value:function(e,t){var r=this._getComplexVisual();if(r){var i=e;(0,n.isString)(e)&&(i=iu.parse(e).selector),r.select(i,t),this._lastPick=null,this._updateInfoPanel(),this._needRender=!0}}},{key:"view",value:function(e){var t,r,n,o=this,a=this._gfx.pivot,s=[];return void 0===e?(t=a.position,r=o._objectControls.getScale()/J.now.radiusToFit,(n=new i.USm).setFromQuaternion(o._objectControls.getOrientation(),"ZXY"),s=[t.x,t.y,t.z,r,n.x,n.y,n.z],"1"+$.arrayToBase64(s,Float32Array)):(function(){40===e.length&&(e="0".concat(e));var t=e[0];if(s=$.arrayFromBase64(e.substr(1),Float32Array),"1"!==t){if("0"!==t)return void o.logger.warn("Encoded view version mismatch, stored as ".concat(t," vs ").concat("1"," expected"));s[3]/=8}var r=o._interpolator,n=r.createView();n.position.copy(a.position),n.scale=o._objectControls.getScale(),n.orientation.copy(o._objectControls.getOrientation());var l=r.createView();l.position.set(s[0],s[1],s[2]),o._getComplexVisual()&&l.position.sub(o._getComplexVisual().position),l.scale=s[3],l.orientation.setFromEuler(new i.USm(s[4],s[5],s[6],"ZXY")),r.setup(n,l)}(),e)}},{key:"_updateView",value:function(){var e=this,t=this._gfx.pivot,r=this._interpolator;if(r.wasStarted()||r.start(),r.isMoving()){var n=r.getCurrentView();if(n.success){var i=n.view;t.position.copy(i.position),e._objectControls.setScale(i.scale*J.now.radiusToFit),e._objectControls.setOrientation(i.orientation),this.dispatchEvent({type:"transform"}),e._needRender=!0}}}},{key:"translate",value:function(e,t,r){this._objectControls.translatePivot(e,t,r),this.dispatchEvent({type:"transform"}),this._needRender=!0}},{key:"rotate",value:function(e,t,r){this._objectControls.rotate((new i._fP).setFromEuler(new i.USm(e,t,r,"XYZ"))),this.dispatchEvent({type:"transform"}),this._needRender=!0}},{key:"scale",value:function(e){if(e<=0)throw new RangeError("Scale should be greater than zero");this._objectControls.scale(e),this.dispatchEvent({type:"transform"}),this._needRender=!0}},{key:"center",value:function(e){if(void 0===e)return this.setPivotSubset(),void(this._needRender=!0);if(void 0!==e.obj&&("atom"in e.obj||"residue"in e.obj))return"atom"in e.obj?this.setPivotAtom(e.obj.atom):this.setPivotResidue(e.obj.residue),void(this._needRender=!0);if(void 0===e.obj&&""!==e){var t=iu.parse(e);if(void 0===t.error)return this.setPivotSubset(t),void(this._needRender=!0)}this.resetPivot(),this._needRender=!0}},{key:"within",value:function(e,t){var r=this._getComplexVisual();if(!r)return iu.None();e instanceof String&&(e=iu.parse(e));var n=r.within(e,t);return n&&(r.rebuildSelectionGeometry(),this._needRender=!0),n}},{key:"projected",value:function(e,t){var r=this._getComplexVisual(t);if(!r)return!1;var n=r.getComplex().getAtomByFullname(e);if(null===n)return!1;var i=n.position.clone();return this._gfx.pivot.updateMatrixWorldRecursive(),this._gfx.camera.updateMatrixWorldRecursive(),this._gfx.pivot.localToWorld(i),i.project(this._gfx.camera),{x:.5*(i.x+1)*this._gfx.width,y:.5*(1-i.y)*this._gfx.height}}},{key:"dssp",value:function(e){var t=this._getComplexVisual(e);t&&(t.getComplex().dssp(),t._reprList.forEach((function(e){"CA"!==e.mode.id&&"SS"!==e.colorer.id||(e.needsRebuild=!0)})))}},{key:"exportCML",value:function(){var e=this,t=e._getComplexVisual(),r=t?t.getComplex():null;return r&&r.originalCML?(function(t){var r=function(e){var t=new i.Pa4,r=new i.Pa4,n=new i.Pa4;e.extractBasis(t,r,n),t.normalize(),r.normalize(),n.normalize();var o=new i.yGw;return o.identity(),o.makeBasis(t,r,n),o}(e._gfx.root.matrixWorld),n=new i.Ltg(0,0,0,0),o=new i.Ltg(0,0,0,0),a=null,s=null;t.forEachAtom((function(e){e.xmlNodeRef&&e.xmlNodeRef.xmlNode&&(a=e.xmlNodeRef.xmlNode,s=e.position,n.set(s.x,s.y,s.z,1),n.applyMatrix4(r),a.setAttribute("x3",n.x.toString()),a.setAttribute("y3",n.y.toString()),a.setAttribute("z3",n.z.toString()),a.removeAttribute("x2"),a.removeAttribute("y2"))})),t.forEachSGroup((function(e){if(e.xmlNodeRef&&e.xmlNodeRef.xmlNode){a=e.xmlNodeRef.xmlNode,s=e.getPosition(),n.set(s.x,s.y,s.z,1);var t=e.getCentralPoint();null===t?n.applyMatrix4(r):(o.set(t.x,t.y,t.z,0),n.add(o),n.applyMatrix4(r),o.set(t.x,t.y,t.z,1),o.applyMatrix4(r),n.sub(o)),a.setAttribute("x",n.x.toString()),a.setAttribute("y",n.y.toString()),a.setAttribute("z",n.z.toString())}}))}(r),(new XMLSerializer).serializeToString(r.originalCML)):null}},{key:"motm",value:function(){J.set({fogColorEnable:!0,fogColor:0,outline:{on:!0,threshold:.01},bg:{color:16777215}}),this._forEachComplexVisual((function(e){for(var t=[],r=e.getComplex(),n=na.get(J.now.palette),i=0;i2&&w.push("'"+this.terminals_[g]+"'");R=u.showPosition?"Parse error on line "+(s+1)+":\n"+u.showPosition()+"\nExpecting "+w.join(", ")+", got '"+(this.terminals_[m]||m)+"'":"Parse error on line "+(s+1)+": Unexpected "+(1==m?"end of input":"'"+(this.terminals_[m]||m)+"'"),this.parseError(R,{text:u.match,token:this.terminals_[m]||m,line:u.yylineno,loc:d,expected:w})}if(y[0]instanceof Array&&y.length>1)throw new Error("Parse Error: multiple actions possible at state: "+v+", token: "+m);switch(y[0]){case 1:t.push(m),n.push(u.yytext),i.push(u.yylloc),t.push(y[1]),m=null,l=u.yyleng,a=u.yytext,s=u.yylineno,d=u.yylloc;break;case 2:if(x=this.productions_[y[1]][1],C.$=n[n.length-x],C._$={first_line:i[i.length-(x||1)].first_line,last_line:i[i.length-1].last_line,first_column:i[i.length-(x||1)].first_column,last_column:i[i.length-1].last_column},p&&(C._$.range=[i[i.length-(x||1)].range[0],i[i.length-1].range[1]]),void 0!==(_=this.performAction.apply(C,[a,l,s,h.yy,y[1],n,i].concat(c))))return _;x&&(t=t.slice(0,-1*x*2),n=n.slice(0,-1*x),i=i.slice(0,-1*x)),t.push(this.productions_[y[1]][0]),n.push(C.$),i.push(C._$),b=o[t[t.length-2]][t[t.length-1]],t.push(b);break;case 3:return!0}}return!0}},ge=function(){var e={EOF:1,parseError:function(e,t){if(!this.yy.parser)throw new Error(e);this.yy.parser.parseError(e,t)},setInput:function(e,t){return this.yy=t||this.yy||{},this._input=e,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},input:function(){var e=this._input[0];return this.yytext+=e,this.yyleng++,this.offset++,this.match+=e,this.matched+=e,e.match(/(?:\r\n?|\n).*/g)?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),e},unput:function(e){var t=e.length,r=e.split(/(?:\r\n?|\n)/g);this._input=e+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-t),this.offset-=t;var n=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),r.length-1&&(this.yylineno-=r.length-1);var i=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:r?(r.length===n.length?this.yylloc.first_column:0)+n[n.length-r.length].length-r[0].length:this.yylloc.first_column-t},this.options.ranges&&(this.yylloc.range=[i[0],i[0]+this.yyleng-t]),this.yyleng=this.yytext.length,this},more:function(){return this._more=!0,this},reject:function(){return this.options.backtrack_lexer?(this._backtrack=!0,this):this.parseError("Lexical error on line "+(this.yylineno+1)+". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},less:function(e){this.unput(this.match.slice(e))},pastInput:function(){var e=this.matched.substr(0,this.matched.length-this.match.length);return(e.length>20?"...":"")+e.substr(-20).replace(/\n/g,"")},upcomingInput:function(){var e=this.match;return e.length<20&&(e+=this._input.substr(0,20-e.length)),(e.substr(0,20)+(e.length>20?"...":"")).replace(/\n/g,"")},showPosition:function(){var e=this.pastInput(),t=new Array(e.length+1).join("-");return e+this.upcomingInput()+"\n"+t+"^"},test_match:function(e,t){var r,n,i;if(this.options.backtrack_lexer&&(i={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,yy:this.yy,conditionStack:this.conditionStack.slice(0),done:this.done},this.options.ranges&&(i.yylloc.range=this.yylloc.range.slice(0))),(n=e[0].match(/(?:\r\n?|\n).*/g))&&(this.yylineno+=n.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:n?n[n.length-1].length-n[n.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+e[0].length},this.yytext+=e[0],this.match+=e[0],this.matches=e,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._backtrack=!1,this._input=this._input.slice(e[0].length),this.matched+=e[0],r=this.performAction.call(this,this.yy,this,t,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),r)return r;if(this._backtrack){for(var o in i)this[o]=i[o];return!1}return!1},next:function(){if(this.done)return this.EOF;var e,t,r,n;this._input||(this.done=!0),this._more||(this.yytext="",this.match="");for(var i=this._currentRules(),o=0;ot[0].length)){if(t=r,n=o,this.options.backtrack_lexer){if(!1!==(e=this.test_match(r,i[o])))return e;if(this._backtrack){t=!1;continue}return!1}if(!this.options.flex)break}return t?!1!==(e=this.test_match(t,i[n]))&&e:""===this._input?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+". Unrecognized text.\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},lex:function(){return this.next()||this.lex()},begin:function(e){this.conditionStack.push(e)},popState:function(){return this.conditionStack.length-1>0?this.conditionStack.pop():this.conditionStack[0]},_currentRules:function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},topState:function(e){return(e=this.conditionStack.length-1-Math.abs(e||0))>=0?this.conditionStack[e]:"INITIAL"},pushState:function(e){this.begin(e)},stateStackSize:function(){return this.conditionStack.length},options:{"case-insensitive":!0},performAction:function(e,t,r,n){switch(r){case 0:break;case 1:case 2:return"";case 3:return 42;case 4:return 35;case 5:return 77;case 6:case 7:return 78;case 8:return 8;case 9:return 6;case 10:return 82;case 11:return 7;case 12:return 9;case 13:return 59;case 14:return 13;case 15:return 15;case 16:return 17;case 17:return 18;case 18:return 19;case 19:return 20;case 20:return 11;case 21:return 62;case 22:return 64;case 23:return 23;case 24:return 25;case 25:return 26;case 26:return 27;case 27:return 30;case 28:return 34;case 29:return 33;case 30:return 65;case 31:return 66;case 32:return 37;case 33:return 41;case 34:return 43;case 35:return 52;case 36:return 54;case 37:return 55;case 38:return 46;case 39:return 48;case 40:return 45;case 41:return 49;case 42:return 56;case 43:return 58;case 44:return 44;case 45:return 83;case 46:return 84;case 47:return 85;case 48:return 86;case 49:return 87;case 50:return 88;case 51:return 89;case 52:return 90;case 53:return 91;case 54:return 92;case 55:return 93;case 56:return 94;case 57:return 95;case 58:case 59:return 70;case 60:case 61:return 72;case 62:case 63:case 64:return 74;case 65:return 31;case 66:return 36;case 67:return 96;case 68:return 97;case 69:return 98;case 70:return 99;case 71:return t.yytext=e.utils.unquoteString(t.yytext),14;case 72:return 38;case 73:return 5;case 74:return 101;case 75:return 103;case 76:return"\\";case 77:return 28;case 78:return 61;case 79:return 29;case 80:return 57;case 81:return 71}},rules:[/^(?:\s+)/i,/^(?:[#].*)/i,/^(?:\/\/.*)/i,/^(?:([_A-Z0-9\/\+]+==))/i,/^(?:-?[0-9]+(\.[0-9]+)?\b)/i,/^(?:0[xX][0-9A-F]+\b)/i,/^(?:false\b)/i,/^(?:true\b)/i,/^(?:all\b)/i,/^(?:reset\b)/i,/^(?:clear\b)/i,/^(?:build\b)/i,/^(?:help\b)/i,/^(?:load\b)/i,/^(?:get\b)/i,/^(?:set\b)/i,/^(?:set_save\b)/i,/^(?:set_restore\b)/i,/^(?:set_reset\b)/i,/^(?:preset\b)/i,/^(?:motm\b)/i,/^(?:add\b)/i,/^(?:rep\b)/i,/^(?:remove\b)/i,/^(?:hide\b)/i,/^(?:show\b)/i,/^(?:list\b)/i,/^(?:select\b)/i,/^(?:within\b)/i,/^(?:selector\b)/i,/^(?:mode\b)/i,/^(?:color\b)/i,/^(?:material\b)/i,/^(?:view\b)/i,/^(?:unit\b)/i,/^(?:line\b)/i,/^(?:listobj\b)/i,/^(?:removeobj\b)/i,/^(?:rotate\b)/i,/^(?:translate\b)/i,/^(?:scale\b)/i,/^(?:center\b)/i,/^(?:url\b)/i,/^(?:screenshot\b)/i,/^(?:dssp\b)/i,/^(?:file_list\b)/i,/^(?:file_register\b)/i,/^(?:file_delete\b)/i,/^(?:preset_add\b)/i,/^(?:preset_delete\b)/i,/^(?:preset_update\b)/i,/^(?:preset_rename\b)/i,/^(?:preset_open\b)/i,/^(?:create_scenario\b)/i,/^(?:reset_scenario\b)/i,/^(?:delete_scenario\b)/i,/^(?:add_scenario_item\b)/i,/^(?:list_scenario\b)/i,/^(?:s\b)/i,/^(?:mt\b)/i,/^(?:m\b)/i,/^(?:c\b)/i,/^(?:x\b)/i,/^(?:y\b)/i,/^(?:z\b)/i,/^(?:as\b)/i,/^(?:of\b)/i,/^(?:pdb\b)/i,/^(?:delay\b)/i,/^(?:prst\b)/i,/^(?:desc\b)/i,/^(?:((?:"(?:\\.|[^\\"])*"|'(?:\\.|[^\\'])*')))/i,/^(?:([_A-Z0-9]+))/i,/^(?:$)/i,/^(?:\.)/i,/^(?:\/)/i,/^(?:\\)/i,/^(?:-e\b)/i,/^(?:-f\b)/i,/^(?:-s\b)/i,/^(?:-v\b)/i,/^(?:=)/i],conditions:{INITIAL:{rules:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81],inclusive:!0}}};return e}();function xe(){this.yy={}}return _e.lexer=ge,xe.prototype=_e,_e.Parser=xe,new xe}(),Cu={parser:Su},Ru={$help:["Rendering mode shortcut"," BS - balls and sticks mode"," LN - lines mode"," LC - licorice mode"," VW - van der waals mode"," TR - trace mode"," TU - tube mode"," CA - cartoon mode"," SA - isosurface mode"," QS - quick surface mode"," SE - solvent excluded mode"," TX - text mode"],BS:{$help:[" Balls and sticks"," aromrad = #aromatic radius"," atom = #atom radius"," bond = #bond radius"," multibond = #use multibond"," showarom = #show aromatic"," space = #space value\n"]},CA:{$help:[" Cartoon"," arrow = #arrow size"," depth = #depth of surface"," heightSegmentsRatio = "," radius = #tube radius"," tension = #"," width = #secondary width\n"]},LN:{$help:[" Lines"," atom = #atom radius"," chunkarom = "," multibond = #use multibond"," showarom = #show aromatic"," offsarom = \n"]},LC:{$help:[" Licorice"," aromrad = #aromatic radius"," bond = #bond radius"," multibond = #use multibond"," showarom = #show aromatic"," space = #space value\n"]},VW:{$help:[" Van der Waals"," nothing\n"]},TR:{$help:[" Trace"," radius = #tube radius\n"]},TU:{$help:[" Tube"," heightSegmentsRatio = "," radius = #tube radius"," tension = \n"]},SA:{$help:[" Surface"," zClip = #clip z plane\n"]},QS:{$help:[" Quick surface"," isoValue = "," scale = "," wireframe = "," zClip = #clip z plane\n"]},SE:{$help:[" Solvent excluded surface"," zClip = #clip z plane\n"]},TX:{$help:[" Text mode",' template = string that can include "{{ id }}"'," it will be replaced by value, id can be one of next:"," serial, name, type, sequence, residue, chain, hetatm, water\n",' horizontalAlign = {"left", "right", "center"}',' verticalAlign = {"top", "bottom", "middle"}'," dx = #offset along x"," dy = #offset along y"," dz = #offset along z"," fg = #text color modificator"," could be keyword, named color or hex"," fg = #back color modificator"," could be keyword, named color or hex"," showBg = #if set show background"," plate under text"]}},Au={$help:["Coloring mode shortcut"," EL - color by element"," CH - color by chain"," SQ - color by sequence"," RT - color by residue type"," SS - color by secondary structure"," UN - uniform"],UN:{$help:["Parameters of coloring modes customization"," Uniform"," color = #RGB->HEX->dec\n"],color:{$help:Object.keys(na.get(J.now.palette).namedColors).sort().join("\n")}}},Eu={$help:["Material shortcut"," DF - diffuse"," TR - transparent"," SF - soft plastic"," PL - glossy plastic"," ME - metal"," GL - glass"]},ku={$help:["Short (packed) representation description as a set of variables"," s="," selector property"," m=[!:[,...]]"," render mode property"," c=[!:[,...]]"," color mode property"," mt="," material property"],s:{$help:"Selection expression string as it is in menu->representations->selection"},m:Ru,c:Au,mt:Eu},Pu={$help:["Parameters of rendering modes customization: modes","Parameters of colorer customization: colorers","Autobuild: autobuild = (|)"],modes:Ru,colorers:Au},Tu={$help:["help (| )","You can get detailed information about command options",' using "help cmd.opt.opt.[...]"\n'," you can use one line comments"," everything started from (#|//) will be skipped"," Example: >build //some comment\n","List of available commands:"],reset:{$help:["Reload current object, delete all representations"," Nothing will work until load new object"]},load:{$help:["load (||-f [<*.NC FILE URL STRING>])"," Load new pdb object from selected source"],PDBID:{$help:"pdb id in remote molecule database"},URL:{$help:"url to source file"},f:{$help:["open file system dialog to fetch local file","optionally you can determine trajectory file","via URL for *.top model"]}},clear:{$help:"No args. Clear terminal"},add:{$help:["add [] []"," Add new item to representation set with"," default or params"],REP_NAME:{$help:"Identifier string [_,a-z,A-Z,0-9] can not start from digit"},DESCRIPTION:ku},rep:{$help:["rep [|] []"," set current representation by name or index"," edit current representation by "],REP_NAME:{$help:["Identifier string [_,a-z,A-Z,0-9] can not start from digit","Must be declared before"]},REP_INDEX:{$help:"Index of available representation"},DESCRIPTION:ku},remove:{$help:["remove (|)","Remove representation by name or index"],REP_NAME:{$help:["Identifier string [_,a-z,A-Z,0-9] can not start from digit","Must be declared before"]},REP_INDEX:{$help:"Index of available representation"}},selector:{$help:["selector "," set selector from EXPRESSION to current representation"],EXPRESSION:{$help:"Selection expression string as it is in menu->representations->selection"}},mode:{$help:["mode [=...]"," set rendering mode and apply parameters to current representation"],MODE_ID:Ru},color:{$help:["color [=...]"," set colorer and apply parameters to current representation"],COLORER_ID:Au},material:{$help:["material "," set material to current representation"],MATERIAL_ID:Eu},build:{$help:"build help str",add:{$help:"build.add",new:{$help:["add.new","add.new new line 1","add.new new line 2","add.new new line 3"]}},del:{$help:"build.del"}},list:{$help:["list [-e|-s||]","Print representations if no args print list of representations"," -e expand list and show all representations"," -s show all user-registered selectors"," | show only current representation"]},hide:{$help:["hide (|)","Hide representation referenced in args"]},show:{$help:["show (|)","Show representation referenced in args"]},get:{$help:["get ","Print value"," - path to option use get.PARAMETER to get more info"],PARAMETER:Pu},set:{$help:["set ","Set with